/** * Controller init. * @param Backend $backend * @param ViewFactory $view */ public function init(Backend $backend, ViewFactory $view) { $backend->setActiveMenu('system.users'); $view->composer($this->viewName('users.form'), function (View $view) { $view->with('groups', GroupModel::query()->get()); }); }
/** * Init controller. * @param Backend $backend * @param ViewFactory $view */ public function init(Backend $backend, ViewFactory $view) { $backend->setActiveMenu('system.groups'); $view->composer($this->viewName('groups.form'), function (View $view) use($backend) { $view->with('rules', $backend->getAclGroups()); }); }
/** * Define acl as gate permissions. * * @param Gate $gate * @param Backend $backend */ public function boot(Gate $gate, Backend $backend) { $this->app->booted(function () use($gate, $backend) { foreach ($backend->getAllAcl() as $acl => $label) { $gate->define($acl, function ($user) use($acl) { return $user instanceof User ? $user->hasAccess($acl) : false; }); } }); }