/** * Get allowed roles for the current user. * * @return mixed */ protected function getAllowedRoles() { if ($this->request->user('administrator')->isRole('super-administrator')) { $roles = $this->role->get(); } else { $roles = $this->role->where('slug', '!=', 'super-administrator')->get(); } return $roles; }
/** * Attach a role to user using slug. * * @param $slug * @return bool */ public function attachRoleBySlug($slug) { $role = Role::where('slug', $slug)->first(); return $this->attachRole($role); }