当前位置: 首页>>代码示例>>PHP>>正文


PHP Guard::user方法代码示例

本文整理汇总了PHP中Illuminate\Auth\Guard::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::user方法的具体用法?PHP Guard::user怎么用?PHP Guard::user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Auth\Guard的用法示例。


在下文中一共展示了Guard::user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: grantedRoles

 /**
  * Get all roles of the current user
  * @return array
  */
 protected function grantedRoles()
 {
     $userRoles = $this->guard->user()->roles->toArray();
     return array_map(function ($roles) {
         return $roles['pivot']['role_id'];
     }, $userRoles);
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:11,代码来源:IndexShowCreateUpdateAuth.php

示例2: store

 /**
  * Store a newly created snippet in storage.
  *
  * @param SnippetsRequest $request
  * @return Response
  */
 public function store(SnippetsRequest $request, Guard $auth)
 {
     $data = ['user_id' => $auth->user() ? $auth->user()->id : null];
     $snippet = $this->dispatchFrom(StoreNewSnippetCommand::class, $request, $data);
     flash('Snippet was successfully created.');
     return redirect()->route('snippets.show', $snippet->slug->slug);
 }
开发者ID:elvios,项目名称:darkshare,代码行数:13,代码来源:SnippetsController.php

示例3: authorize

 /**
  * Authorize the post.
  *
  * @param PostInterface $post
  */
 public function authorize(PostInterface $post)
 {
     if (!$post->isEnabled() && !$this->guard->user()) {
         abort(404);
     }
     $this->authorizer->authorize('anomaly.module.posts::view_drafts');
 }
开发者ID:bloveless,项目名称:posts-module,代码行数:12,代码来源:PostAuthorizer.php

示例4: authorize

 /**
  * Authorize the page.
  *
  * @param PageInterface $page
  */
 public function authorize(PageInterface $page)
 {
     /* @var UserInterface $user */
     $user = $this->guard->user();
     /**
      * If the page is not enabled and we
      * are not logged in then 404.
      */
     if (!$page->isEnabled() && !$user) {
         abort(404);
     }
     /**
      * If the page is not enabled and we are
      * logged in then make sure we have permission.
      */
     if (!$page->isEnabled()) {
         $this->authorizer->authorize('anomaly.module.pages::view_drafts');
     }
     /**
      * If the page is restricted to specific
      * roles then make sure our user is one of them.
      */
     $allowed = $page->getAllowedRoles();
     if (!$allowed->isEmpty() && (!$user || !$user->hasAnyRole($allowed))) {
         $page->setResponse($this->response->redirectTo('login'));
     }
 }
开发者ID:visualturk,项目名称:pages-module,代码行数:32,代码来源:PageAuthorizer.php

示例5: store

 /**
  * Store a newly created snippet in storage.
  *
  * @param SnippetsRequest $request
  * @return Response
  */
 public function store(SnippetsRequest $request)
 {
     $this->auth->basic('username');
     $data = ['title' => $request->input('title') ?: null, 'user_id' => $this->auth->user() ? $this->auth->id() : null, 'password' => $request->input('password') ?: null, 'mode' => $request->input('mode') ?: 'markdown'];
     $snippet = $this->dispatchFrom(StoreNewSnippetCommand::class, $request, $data);
     return 'http://drk.sh/s/' . $snippet->slug->slug . PHP_EOL;
 }
开发者ID:elvios,项目名称:darkshare,代码行数:13,代码来源:SnippetsController.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check() && $this->auth->user()['status'] === 'student') {
         return $next($request);
     }
     Session::push('messages', 'danger|Vous devez être étudiant pour accéder à cette page');
     return redirect('/');
 }
开发者ID:Kocal,项目名称:IUT-MethodoProd-QCM,代码行数:16,代码来源:Student.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $user = $this->auth->user();
     if ($user->user_type != SiteConstants::USER_ADMIN) {
         return redirect('auth/logout');
     }
     return $next($request);
 }
开发者ID:talenthub2015,项目名称:talenthub-website,代码行数:15,代码来源:Admin.php

示例8: handle

 /**
  * Handle incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // check if this an auth.shield instance
     if ($this->config->get('auth.driver') === 'classid.shield') {
         $this->auth->user();
     }
     return $next($request);
 }
开发者ID:classid,项目名称:core-auth,代码行数:16,代码来源:ResolveAuthUser.php

示例9: __construct

 /**
  * Create a new PreferenceRepositoryInterface instance.
  *
  * @param Guard           $auth
  * @param PreferenceModel $model
  */
 public function __construct(Guard $auth, PreferenceModel $model)
 {
     $this->auth = $auth;
     $this->model = $model;
     $this->preferences = new PreferenceCollection();
     if ($user = $this->auth->user()) {
         $this->preferences = $this->model->belongingToUser($auth->getUser())->get();
     }
 }
开发者ID:visualturk,项目名称:preferences-module,代码行数:15,代码来源:PreferenceRepository.php

示例10: show

 public function show($id, Guard $auth)
 {
     if ($auth->user()->id == $id) {
         $personne = User::findOrFail($id);
         return view('parents.show', compact('personne'));
     }
     $personne = User::findOrFail($auth->user()->id);
     return redirect()->action('UserController@show', $auth->user()->id);
 }
开发者ID:InfoTeamUPS,项目名称:projetTarabel,代码行数:9,代码来源:UserController.php

示例11: save

 /**
  * Save activity
  *
  * @param $activity
  * @return bool
  */
 public function save($activity)
 {
     $activity['user_id'] = null;
     $user = $this->auth->user();
     if (isset($user->id)) {
         $activity['user_id'] = $user->id;
     }
     return $this->activity->create($activity) ? true : false;
 }
开发者ID:sadhakbj,项目名称:resourcecontracts.org,代码行数:15,代码来源:ActivityRepository.php

示例12: update

 /**
  * @param Post $post
  * @param array $attributes
  * @return static
  */
 public function update($post, array $attributes = array())
 {
     $attributes['created_by'] = $this->user->user()->id;
     if (!isset($attributes['state']) || empty($attributes['state'])) {
         $attributes['state'] = 0;
     }
     $post->update($attributes);
     return $post;
 }
开发者ID:vnzacky,项目名称:dog,代码行数:14,代码来源:EloquentPostRepository.php

示例13: __construct

 /**
  * @param UserService    $user
  * @param CountryService $country
  * @param Guard          $auth
  */
 public function __construct(UserService $user, CountryService $countries, Guard $auth)
 {
     $this->middleware('auth');
     $this->user = $user;
     $this->auth = $auth;
     if (!$this->auth->user()->hasRole(['superadmin', 'admin', 'country-admin'])) {
         return redirect('/home')->withError(trans('contract.permission_denied'))->send();
     }
     $this->countries = $countries;
 }
开发者ID:sadhakbj,项目名称:resourcecontracts.org,代码行数:15,代码来源:UserController.php

示例14: handle

 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         return redirect()->guest('login');
     }
     if ($this->auth->check() && !$this->auth->user()->isAdmin()) {
         App::abort('403');
     }
     return $next($request);
 }
开发者ID:studiocaro,项目名称:HorseStories,代码行数:10,代码来源:Admin.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         if ($this->auth->user()->allowRoutes($request->route()->getName())) {
             return $next($request);
         }
         return response('Forbidden.', 403);
     }
     return $next($request);
 }
开发者ID:bitw,项目名称:acl-example,代码行数:17,代码来源:Access.php


注:本文中的Illuminate\Auth\Guard::user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。