Пример #1
0
 /**
  * @param $userId
  * @param $data
  * @param $roles
  * @internal param $user
  * @return mixed
  */
 public function updateAndSyncRoles($userId, $data, $roles)
 {
     $user = $this->user->find($userId);
     $user = $this->update($user, $data);
     if (!empty($roles) && is_array($roles)) {
         foreach ($roles as $id) {
             $role = $this->role->find($id);
             $user->assignRole($role);
         }
     }
     $this->user->persist($user);
     $this->user->flush();
     return $user;
 }
Пример #2
0
 /**
  * Find a role by its name
  * @param  string $name
  * @return mixed
  */
 public function findByName($name)
 {
     return $this->role->findByName($name);
 }