private function tableSeed()
 {
     $adminCapabilities = Capability::all();
     $userCapabilities = Capability::whereIn('name', ['login', 'logout', 'access_admin_dashboard'])->get();
     $staffCapabilities = Capability::whereIn('name', ['login', 'logout', 'access_admin_dashboard', 'update_user_profile', 'update_user_password'])->get();
     $admins = Role::whereName('admin')->get();
     $staff = Role::whereName('staff')->get();
     $users = Role::whereName('user')->get();
     foreach ($admins as $admin) {
         $admin->capabilities()->sync($adminCapabilities->lists('id'));
     }
     foreach ($staff as $staff) {
         $staff->capabilities()->sync($staffCapabilities->lists('id'));
     }
     foreach ($users as $user) {
         $user->capabilities()->sync($userCapabilities->lists('id'));
     }
 }
 public function run()
 {
     // users related capabilities
     Capability::create(['name' => 'list_users', 'category' => 'users']);
     Capability::create(['name' => 'register_other_users', 'category' => 'users']);
     Capability::create(['name' => 'login', 'category' => 'users']);
     Capability::create(['name' => 'logout', 'category' => 'users']);
     Capability::create(['name' => 'update_user_password', 'category' => 'users']);
     Capability::create(['name' => 'update_other_users_password', 'category' => 'users']);
     Capability::create(['name' => 'update_user_profile', 'category' => 'users']);
     Capability::create(['name' => 'update_other_users_profile', 'category' => 'users']);
     Capability::create(['name' => 'update_user_roles', 'category' => 'users']);
     Capability::create(['name' => 'delete_user', 'category' => 'users']);
     Capability::create(['name' => 'restore_user', 'category' => 'users']);
     // roles related capabilities
     Capability::create(['name' => 'list_roles', 'category' => 'roles']);
     Capability::create(['name' => 'create_new_role', 'category' => 'roles']);
     Capability::create(['name' => 'delete_role', 'category' => 'roles']);
     Capability::create(['name' => 'update_role', 'category' => 'roles']);
 }
 /**
  * @param $roleId
  * @param $name
  * @param $capabilities
  *
  * @return mixed
  */
 public static function updateRights($roleId, $name, $capabilities)
 {
     $role = self::findOrFail($roleId);
     $capabilities = $capabilities ? Capability::find($capabilities) : new Collection();
     $role->capabilities()->sync($capabilities->lists('id'));
     $role->update(compact('name'));
     $role->raise(new RoleWasUpdated($role));
     return $role;
 }