public function registerMarkupTags() { return ['functions' => ['can' => function ($can) { return UserGroup::can($can); }, 'hasRole' => function ($can) { return UserGroup::hasRole($can); }]]; }
public function index_onDelete() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { foreach ($checkedIds as $roleId) { if (!($role = UserGroup::find($roleId))) { continue; } $role->delete(); } Flash::success('The role has been deleted successfully.'); } return $this->listRefresh(); }
public function onRun() { $userPermision = $this->property('permission'); if ($userPermision) { if (!UserGroup::can($userPermision)) { return; } } $person = user::find(intval($this->property('SLSlug'))); if ($person) { $filename = $person->surname . '_' . $person->name . '.vcf'; return response($this->renderPartial('@vcard', ['person' => $person]))->header('Content-Type', 'text/directory')->header('Content-Disposition', 'attachment; filename=' . $filename)->header('Pragma', 'public'); } }
public static function can($permissions) { $account = new Account(); $permissions = !is_array($permissions) ? [$permissions] : $permissions; if (Auth::check()) { $roles = json_decode(User::find($account->user()->id)->groups); foreach ($roles as $role) { foreach (UserGroup::find($role->id)->perms as $perm) { if (in_array($perm->name, $permissions)) { return true; } } } } }
public function getPrimaryUsergroupOptions() { return UserGroup::lists('name', 'id'); }
public function getPrimaryUsergroups() { $this->userGroups = UserGroup::lists('name', 'id'); $this->page['userGroups'] = $this->userGroups; }