Esempio n. 1
0
 /**
  *
  * Force the user to have the given role.
  *
  * @param $roleName
  */
 public function forceRole($roleName)
 {
     // If the user is not a member to the given role,
     if (null == $this->roles()->where('name', $roleName)->first()) {
         // Load the given role and attach it to the user.
         $roleToForce = Role::where('name', $roleName)->first();
         $this->roles()->attach($roleToForce->id);
     }
 }