コード例 #1
0
 /**
  * Fired when builder is ready to build.
  *
  * @param UserRepositoryInterface $users
  * @param BreadcrumbCollection    $breadcrumbs
  * @param MessageBag              $messages
  * @param Redirector              $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function onReady(UserRepositoryInterface $users, RoleRepositoryInterface $roles, BreadcrumbCollection $breadcrumbs, MessageBag $messages, Redirector $redirect)
 {
     $this->setEntry($user = $users->find($this->getEntry()));
     if ($user->hasRole($roles->findBySlug('admin'))) {
         $messages->warning('anomaly.module.users::warning.modify_admin_user');
         $this->setFormResponse($redirect->to('admin/users'));
         return;
     }
     $breadcrumbs->add($user->getDisplayName(), 'admin/users/edit/' . $user->getId());
     $breadcrumbs->add('anomaly.module.users::breadcrumb.permissions', 'admin/users/permissions/' . $user->getId());
 }
コード例 #2
0
ファイル: GetUser.php プロジェクト: jacksun101/users-module
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @param Guard                   $auth
  * @return \Anomaly\UsersModule\User\Contract\UserInterface|\Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function handle(UserRepositoryInterface $users, Guard $auth)
 {
     if (is_null($this->identifier)) {
         return $auth->user();
     }
     if (is_numeric($this->identifier)) {
         return $users->find($this->identifier);
     }
     if (filter_var($this->identifier, FILTER_VALIDATE_EMAIL)) {
         return $users->findByEmail($this->identifier);
     }
     if (!is_numeric($this->identifier)) {
         return $users->findByUsername($this->identifier);
     }
     return null;
 }