classname() public static method

Get the classname mapping for the given model.
public static classname ( string $model ) : string
$model string
return string
Ejemplo n.º 1
0
 /**
  * Map a list of authorities by their class name.
  *
  * @param  array  $authorities
  * @return array
  */
 public static function mapAuthorityByClass(array $authorities)
 {
     $map = [];
     foreach ($authorities as $authority) {
         if ($authority instanceof Model) {
             $map[get_class($authority)][] = $authority->getKey();
         } else {
             $map[Models::classname(User::class)][] = $authority;
         }
     }
     return $map;
 }
Ejemplo n.º 2
0
 /**
  * The roles relationship.
  *
  * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
  */
 public function roles()
 {
     return $this->belongsToMany(Models::classname(Role::class), Models::table('user_roles'), 'user_id');
 }
Ejemplo n.º 3
0
 /**
  * The Abilities relationship.
  *
  * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
  */
 public function abilities()
 {
     return $this->belongsToMany(Models::classname(Ability::class), 'user_abilities');
 }
 /**
  * Get the table for the given type.
  *
  * @param  string  $type
  * @return string
  */
 protected function table($type)
 {
     $class = Models::classname($type);
     return (new $class())->getTable();
 }
Ejemplo n.º 5
0
 /**
  * The users relationship.
  *
  * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
  */
 public function users()
 {
     return $this->belongsToMany(Models::classname(User::class));
 }
Ejemplo n.º 6
0
 /**
  * The Permissions relationship.
  *
  * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
  */
 public function permissions()
 {
     return $this->belongsToMany(Models::classname(Permission::class));
 }
Ejemplo n.º 7
0
 /**
  * The roles relationship.
  *
  * @return \Illuminate\Database\Eloquent\Relations\MorphToMany
  */
 public function roles()
 {
     return $this->morphToMany(Models::classname(Role::class), 'entity', Models::table('assigned_roles'));
 }
Ejemplo n.º 8
0
 /**
  * The users relationship.
  *
  * @return \Illuminate\Database\Eloquent\Relations\MorphToMany
  */
 public function users()
 {
     return $this->morphedByMany(Models::classname(User::class), 'entity', Models::table('permissions'));
 }
Ejemplo n.º 9
0
 /**
  * The abilities relationship.
  *
  * @return \Illuminate\Database\Eloquent\Relations\MorphToMany
  */
 public function abilities()
 {
     return $this->morphToMany(Models::classname(Ability::class), 'entity', Models::table('permissions'));
 }
Ejemplo n.º 10
0
 /**
  * The users relationship.
  *
  * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
  */
 public function users()
 {
     return $this->belongsToMany(Models::classname(User::class), Models::table('user_abilities'));
 }