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.']);
 }
예제 #2
0
 /**
  * @param $name
  * @return mixed
  */
 public function update($name)
 {
     if (Auth::user()->hasAccessTo('change', 'any', 'role')) {
         $role = Role::find($name);
         $allActions = Action::all();
         $allOwnerships = Ownership::all();
         $allEntities = Entity::all();
         if (Input::has('permissions')) {
             $role->permissions()->delete();
             foreach (Input::get('permissions') as $entity => $actions) {
                 foreach ($actions as $action => $ownership) {
                     if ('no' != $ownership) {
                         $currentAction = $allActions->find($action);
                         $currentOwnership = $allOwnerships->find($ownership);
                         $currentEntity = $allEntities->find($entity);
                         $currentPermission = new Permission();
                         $currentPermission->ownership()->associate($currentOwnership);
                         $currentPermission->action()->associate($currentAction);
                         $currentPermission->role()->associate($role);
                         $currentPermission->entity()->associate($currentEntity);
                         $currentPermission->save();
                     }
                 }
             }
         }
         $role->fill(Input::only(['name', 'description']));
         $role->save();
         return redirect()->route('roles.index');
     }
 }