2016-09-01 16:23:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2016-09-11 07:19:11 +01:00
|
|
|
use App\User;
|
2016-09-01 16:23:39 +01:00
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
2016-09-21 12:10:37 +01:00
|
|
|
use Illuminate\Http\Request;
|
2016-09-01 16:23:39 +01:00
|
|
|
use Illuminate\Routing\Controller as BaseController;
|
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
2017-04-15 09:41:15 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2016-09-21 12:10:37 +01:00
|
|
|
use Illuminate\Support\Facades\Artisan;
|
2016-09-11 07:19:11 +01:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2016-09-21 12:10:37 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2016-09-01 16:23:39 +01:00
|
|
|
|
|
|
|
class Controller extends BaseController
|
|
|
|
{
|
|
|
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
2016-09-11 07:19:11 +01:00
|
|
|
|
2017-04-15 09:41:15 +01:00
|
|
|
protected function authorizeAccessToAdminPanel($additionalPermission = null)
|
2017-03-21 21:48:55 +00:00
|
|
|
{
|
2017-04-15 09:41:15 +01:00
|
|
|
$this->authorizeForUser($this->getUser(), 'admin:access');
|
|
|
|
|
|
|
|
if (!is_null($additionalPermission))
|
2017-03-21 21:48:55 +00:00
|
|
|
{
|
2017-04-15 09:41:15 +01:00
|
|
|
$this->authorizeForUser($this->getUser(), $additionalPermission);
|
2017-03-21 21:48:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-11 07:19:11 +01:00
|
|
|
/**
|
|
|
|
* Gets either the authenticated user, or a user object representing the anonymous user.
|
|
|
|
* @return User
|
|
|
|
*/
|
|
|
|
protected function getUser()
|
|
|
|
{
|
|
|
|
$user = Auth::user();
|
|
|
|
return (is_null($user)
|
|
|
|
? User::anonymous()
|
|
|
|
: $user);
|
|
|
|
}
|
2016-09-01 16:23:39 +01:00
|
|
|
}
|