user() public static method

Get an instance of the user model.
public static user ( array $attributes = [] ) : Model
$attributes array
return Illuminate\Database\Eloquent\Model
 /**
  * Migrate the data from the user_abilities table.
  *
  * @return void
  */
 protected function migrateUserAbilities()
 {
     $pivots = DB::table('user_abilities')->get();
     $type = Models::user()->getMorphClass();
     $records = array_map(function ($pivot) use($type) {
         return ['ability_id' => $pivot->ability_id, 'entity_type' => $type, 'entity_id' => $pivot->user_id];
     }, $this->toArray($pivots));
     DB::table('permissions')->insert($records);
 }
Example #2
0
 /**
  * Clear the cache.
  *
  * @param  null|int|\Illuminate\Database\Eloquent\Model  $user
  * @return $this
  */
 public function refresh($user = null)
 {
     if (!is_null($user)) {
         return $this->refreshFor($user);
     }
     if ($this->cache instanceof TaggedCache) {
         $this->cache->flush();
         return $this;
     }
     foreach (Models::user()->lists('id') as $id) {
         $this->refreshFor($id);
     }
     return $this;
 }
 /**
  * Get the table name for the user model.
  *
  * @return string
  */
 protected function users()
 {
     return Models::user()->getTable();
 }
 /**
  * Set the classname of the user model to be used by Bouncer.
  *
  * @return void
  */
 protected function setUserModel()
 {
     $config = $this->app->make('config');
     $model = $config->get('auth.providers.users.model', function () use($config) {
         return $config->get('auth.model', \App\User::class);
     });
     Models::setUsersModel($model);
     Models::setTables(['users' => Models::user()->getTable()]);
 }
Example #5
0
 /**
  * Refresh the cache for all roles and users, iteratively.
  *
  * @return void
  */
 protected function refreshAllIteratively()
 {
     foreach (Models::user()->all() as $user) {
         $this->refreshFor($user);
     }
     foreach (Models::role()->all() as $role) {
         $this->refreshFor($role);
     }
 }
Example #6
0
 /**
  * Refresh the cache for all users, iteratively.
  *
  * @return $this
  */
 protected function refreshForAllUsersIteratively()
 {
     $user = Models::user();
     foreach ($user->lists($user->getKeyName()) as $id) {
         $this->refreshFor($id);
     }
     return $this;
 }
Example #7
0
 /**
  * Get the IDs of the users that already have the given role.
  *
  * @param  \Silber\Bouncer\Database\Role  $role
  * @param  array  $ids
  * @return \Illuminate\Support\Collection
  */
 protected function getUsersWithRole(Role $role, array $ids)
 {
     $model = Models::user();
     $column = $model->getTable() . '.' . $model->getKeyName();
     return $role->users()->whereIn($column, $ids)->lists($column);
 }