mapAuthorityByClass() public static method

Map a list of authorities by their class name.
public static mapAuthorityByClass ( array $authorities ) : array
$authorities array
return array
Esempio n. 1
0
 /**
  * Assign the role to the given authority.
  *
  * @param  \Illuminate\Database\Eloquent\Model|array|int  $authority
  * @return bool
  */
 public function to($authority)
 {
     $authorities = is_array($authority) ? $authority : [$authority];
     foreach (Helper::mapAuthorityByClass($authorities) as $class => $keys) {
         $this->assignRole($this->role(), $class, $keys);
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Remove the role from the given authority.
  *
  * @param  \Illuminate\Database\Eloquent\Model|array|int  $authority
  * @return bool
  */
 public function from($authority)
 {
     if (is_null($role = $this->role())) {
         return false;
     }
     $authorities = is_array($authority) ? $authority : [$authority];
     foreach (Helper::mapAuthorityByClass($authorities) as $class => $keys) {
         $role->retractFrom($class, $keys);
     }
     return true;
 }