/** * Create User Groups / Roles * * @return GroupInterface Returns the Administrator group */ public function create_user_groups() { $admin_group = null; try { $admin_group = $this->sentry->createGroup($this->groups['administrator']); $this->sentry->createGroup($this->groups['owner']); $this->sentry->createGroup($this->groups['moderator']); } catch (NameRequiredException $e) { $this->abort_command('Name field is required'); } catch (GroupExistsException $e) { $this->abort_command('Group already exists'); } return $admin_group; }
/** * Store a newly created resource in storage. * * @return Response */ public function store($data) { $result = []; try { // Create the group $group = $this->sentry->createGroup(['name' => e($data['name']), 'permissions' => $data['permissions']]); $result['success'] = true; $result['message'] = trans('groups.created'); } catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) { $result['success'] = false; $result['message'] = trans('groups.namereq'); } catch (\Cartalyst\Sentry\Groups\GroupExistsException $e) { $result['success'] = false; $result['message'] = trans('groups.exists'); } return $result; }
/** * Creates a group. * * @param array $attributes * @return \Cartalyst\Sentry\Groups\GroupInterface * @static */ public static function createGroup($attributes) { return \Cartalyst\Sentry\Sentry::createGroup($attributes); }