-
src/AuthServiceProvider.php
Open in GitHubuse Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Gate; class AuthServiceProvider extends ServiceProvider { // public function boot() { Gate::define('list', function ($user) { return $this->authorize($user, function ($user) { return $this->userHasRole($user, [UserRole::VIEWONLY, UserRole::PUBLISHER, UserRole::ADMIN]); }); }); Gate::define('edit', function ($user) { return $this->authorize($user, function ($user) { return $this->userHasRole($user, [UserRole::PUBLISHER, UserRole::ADMIN]); }); }); Gate::define('reorder', function ($user) { return $this->authorize($user, function ($user) { return $this->userHasRole($user, [UserRole::PUBLISHER, UserRole::ADMIN]); }); }); Gate::define('publish', function ($user) { return $this->authorize($user, function ($user) { return $this->userHasRole($user, [UserRole::PUBLISHER, UserRole::ADMIN]); }); }); // } }
-
src/Http/Controllers/Admin/ModuleController.php
Open in GitHubabstract class ModuleController extends Controller { public function __construct(Application $app, Request $request) { parent::__construct(); $this->app = $app; $this->request = $request; $this->setMiddlewarePermission(); // } protected function setMiddlewarePermission() { $this->middleware('can:list', ['only' => ['index', 'show']]); $this->middleware('can:edit', ['only' => ['store', 'edit', 'update']]); $this->middleware('can:duplicate', ['only' => ['duplicate']]); $this->middleware('can:publish', ['only' => ['publish', 'feature', 'bulkPublish', 'bulkFeature']]); $this->middleware('can:reorder', ['only' => ['reorder']]); $this->middleware('can:delete', ['only' => ['destroy', 'bulkDelete', 'restore', 'bulkRestore', 'forceDelete', 'bulkForceDelete', 'restoreRevision']]); } // }