/** * Register administrator view composers. */ protected function bootAdministratorViewComposer() { view()->composer('administrator.widgets.*', function (View $view) { /** @var \Yajra\CMS\Themes\Repositories\Repository $themes */ $themes = $this->app['themes']; $theme = $themes->current(); $positions = $theme->positions; $data = []; foreach ($positions as $position) { $data[$position] = Str::title($position); } $view->with('widget_positions', $data); $view->with('theme', $theme); /** @var \Yajra\CMS\Repositories\Extension\Repository $extensions */ $extensions = $this->app['extensions']; $widgets = $extensions->allWidgets()->filter(function ($extension) { return $extension->enabled; }); $view->with('extensions', $widgets); }); view()->composer(['administrator.partials.permissions'], function (View $view) { $view->with('permissions', Permission::orderBy('resource')->get()); }); view()->composer(['system.macro.image-browser'], function (View $view) { $view->with('mediaDirectories', $this->getFileDirectories()); }); }
/** * Show and edit selected role. * * @param \Yajra\Acl\Models\Role $role * @return \Illuminate\View\View */ public function edit(Role $role) { $permissions = Permission::all(); return view('administrator.roles.edit', compact('role', 'permissions')); }
/** * Remove selected permission. * * @param \Yajra\Acl\Models\Permission $permission * @return \Illuminate\Http\RedirectResponse */ public function destroy(Permission $permission) { if (!$permission->system) { try { $permission->delete(); return $this->notifySuccess('Permission successfully deleted!'); } catch (QueryException $e) { return $this->notifyError($e->getMessage()); } } return $this->notifyError('System permission is protected and cannot be deleted!'); }
/** * Register ACL models cache listener. */ protected function registerCacheListener() { Permission::saved(function () { $this->app['cache.store']->forget('permissions.policies'); }); Permission::deleted(function () { $this->app['cache.store']->forget('permissions.policies'); }); Role::saved(function () { $this->app['cache.store']->forget('permissions.policies'); }); Role::deleted(function () { $this->app['cache.store']->forget('permissions.policies'); }); }
/** * @return \Illuminate\Database\Eloquent\Builder */ public function query() { return Permission::query(); }