/**
  * @return mixed
  */
 public function index()
 {
     if (Auth::user()->hasAccessTo('view', 'any', 'assignment')) {
         $displayNameField = $this->displayNameField;
         $users = $this->user->all();
         $roles = Role::with('users')->get();
         return view('genealabs-bones-keeper::assignments.index', compact('users', 'roles', 'displayNameField', 'userList'));
     }
 }
 public function run()
 {
     $user = App::make(Config::get('auth.model'));
     $superuser = $user->find($user->min($user['primaryKey']));
     $role = new Role();
     $role->name = 'SuperAdmin';
     $role->description = 'This role is for the main administrator of your site. They will be able to do absolutely everything. (This role cannot be edited.)';
     $role->save();
     $role = Role::find('SuperAdmin');
     $role->users()->save($superuser);
     Role::create(['name' => 'Member', 'description' => 'Represents the baseline registered user. Customize permissions as best suits your site.']);
 }
 public function run()
 {
     $superadmin = Role::whereName('SuperAdmin')->get()->first();
     $actions = Action::all();
     $ownership = Ownership::whereName('any')->get()->first();
     $entities = Entity::all();
     foreach ($entities as $entity) {
         foreach ($actions as $action) {
             //                foreach ($ownerships as $ownership) {
             $permission = new Permission();
             $permission->role()->associate($superadmin);
             $permission->action()->associate($action);
             $permission->ownership()->associate($ownership);
             $permission->entity()->associate($entity);
             $permission->save();
             //                    $superadmin->permissions()->attach($permission);
             //                }
         }
     }
     //        $superadmin->save();
 }
Пример #4
0
 public function getAllUsersOfRole($role)
 {
     $role = Role::with('users')->where('name', $role)->first();
     return $role->users;
 }
Пример #5
0
 /**
  * @param $name
  * @return mixed
  */
 public function destroy($name)
 {
     if (Auth::user()->hasAccessTo('remove', 'any', 'role')) {
         Role::destroy($name);
         return redirect()->route('roles.index');
     }
 }
Пример #6
0
 public static function create(array $attributes = [])
 {
     $user = parent::create($attributes);
     $memberRole = Role::findOrFail('Member');
     $user->roles()->attach($memberRole->name);
     return $user;
 }