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


PHP Guard::check方法代码示例

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


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

示例1: filter

 public function filter(Route $route, Request $request)
 {
     if ($this->auth->check()) {
         $config = $this->config->get('c::redirect-login');
         $url = $config ? $this->url->to($config) : '/';
         return $this->redirect->to($url);
     }
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:8,代码来源:GuestFilter.php

示例2: 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()) {
         return redirect('/admin/home');
     }
     return $next($request);
 }
开发者ID:gaurangsudra,项目名称:laravel51-multiauth-socialite,代码行数:14,代码来源:RedirectAdminIfAuthenticated.php

示例3: 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()) {
         return new RedirectResponse(route('login'));
     }
     return $next($request);
 }
开发者ID:imanghafoori1,项目名称:boom-core,代码行数:15,代码来源:RequireLogin.php

示例4: 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

示例5: 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

示例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()) {
         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

示例7: 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()) {
         flash()->message('Please Log In.');
         return new RedirectResponse(url('auth/login'));
     }
     if (!$this->auth->user()->is_admin) {
         flash()->message('Restricted Access!!!');
         return new RedirectResponse(url('user/dashboard'));
     }
     return $next($request);
 }
开发者ID:jbmadking,项目名称:bottlestore,代码行数:20,代码来源:RestrictAdminSection.php

示例8: blueprints

 /**
  * Returns a view with all the blueprints
  * available, irregardless of the user
  * who uploaded them
  *
  * @param Blueprint $blueprint
  * @param Guard     $guard
  *
  * @return $this
  */
 public function blueprints(Blueprint $blueprint, Guard $guard)
 {
     $blueprints = $blueprint->select('blueprint.author_name', 'blueprint.user_id', 'blueprint.id', 'blueprint.name', 'blueprint.bc_version', 'blueprint.screenshot', 'blueprint.archive_name', 'blueprint.description', 'blueprint.version')->with(['mods', 'votes' => function ($query) {
         $query->select('blueprint_user_vote.vote', 'blueprint_user_vote.user_id');
     }, 'user' => function ($query) {
         $query->select('users.id', 'users.name');
     }])->orderBy('uploaded_at', 'desc')->paginate(4);
     $blueprintsAsArray = $blueprints->toArray()['data'];
     foreach ($blueprintsAsArray as $key => $value) {
         if (!empty($value['votes'])) {
             $totalVotes = 0;
             foreach ($value['votes'] as $vote) {
                 // get total number of votes
                 $totalVotes += $vote['vote'];
                 // check if the current user has voted
                 if ($guard->check()) {
                     if ($vote['user_id'] == $guard->user()->getAuthIdentifier()) {
                         $blueprintsAsArray[$key]['user_has_voted'] = true;
                         $blueprintsAsArray[$key]['user_vote'] = $vote['vote'];
                     }
                 }
             }
             $blueprintsAsArray[$key]['total_votes'] = $totalVotes;
         } else {
             $blueprintsAsArray[$key]['user_has_voted'] = false;
             $blueprintsAsArray[$key]['total_votes'] = 0;
         }
     }
     return view('buildcraft.singles')->with(['blueprints' => $blueprints, 'blueprintsAsArray' => $blueprintsAsArray]);
 }
开发者ID:JunkyPic,项目名称:Minecraft-Files,代码行数:40,代码来源:BlueprintController.php

示例9: collections

 public function collections(Collection $collection, Guard $guard)
 {
     $collections = $collection->with(['votes' => function ($query) {
         $query->select('collection_user_vote.vote', 'collection_user_vote.user_id');
     }, 'user' => function ($query) {
         $query->select('users.id', 'users.name');
     }, 'blueprints' => function ($query) {
         $query->select('blueprint.id', 'blueprint.name');
     }])->paginate(8);
     $collectionsAsArray = $collections->toArray()['data'];
     foreach ($collectionsAsArray as $key => $value) {
         if (!empty($value['votes'])) {
             $totalVotes = 0;
             foreach ($value['votes'] as $vote) {
                 // get total number of votes
                 $totalVotes += $vote['vote'];
                 // check if the current user has voted
                 if ($guard->check()) {
                     if ($vote['user_id'] == $guard->user()->getAuthIdentifier()) {
                         $collectionsAsArray[$key]['user_has_voted'] = true;
                         $collectionsAsArray[$key]['user_vote'] = $vote['vote'];
                     }
                 }
             }
             $collectionsAsArray[$key]['total_votes'] = $totalVotes;
         } else {
             $collectionsAsArray[$key]['user_has_voted'] = false;
             $collectionsAsArray[$key]['total_votes'] = 0;
         }
     }
     return view('buildcraft.collections')->with(['collections' => $collections, 'collectionsAsArray' => $collectionsAsArray]);
 }
开发者ID:JunkyPic,项目名称:Minecraft-Files,代码行数:32,代码来源:CollectionController.php

示例10: undo

 /**
  * @param string $topicSlug
  * @param int    $topicId
  *
  * @return \Illuminate\Http\RedirectResponse
  *
  * @throws \Exception
  */
 public function undo($topicSlug, $topicId)
 {
     $topic = $this->topicRepository->find($topicId);
     if (!$topic) {
         throw new TopicNotFoundException();
     }
     if (!$topic->has_poll) {
         throw new PollNotFoundException();
     }
     $poll = $topic->poll;
     $pollPresenter = app()->make('MyBB\\Core\\Presenters\\Poll', [$poll]);
     if (!$this->guard->check()) {
         throw new PollNoGuestUndoException();
     }
     if ($pollPresenter->is_closed) {
         throw new PollClosedException();
     }
     $vote = $this->pollVoteRepository->findForUserPoll($this->guard->user(), $poll);
     if (!$vote) {
         // Error
         throw new PollNoUndoException();
     }
     $votes = explode(',', $vote->vote);
     $options = $pollPresenter->options();
     foreach ($votes as $option) {
         if (is_numeric($option) && 0 < $option && $option <= $pollPresenter->num_options()) {
             $options[$option - 1]['votes']--;
         }
     }
     $poll->update(['options' => $options]);
     $vote->delete();
     return redirect()->route('polls.show', [$topicSlug, $topicId]);
 }
开发者ID:Adamzynoni,项目名称:mybb2,代码行数:41,代码来源:PollController.php

示例11: 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()) {
         $admin = 0;
         if ($this->auth->user()->admin == 1) {
             $admin = 1;
         }
         if ($admin == 0) {
             return $this->response->redirectTo('/');
             // frontend
         }
         return $next($request);
     }
     return $this->response->redirectTo('/');
     // Go to frontend
 }
开发者ID:viethung09,项目名称:kidblog,代码行数:23,代码来源:Admin.php

示例12: postCreate

 /**
  * @param int           $forumId
  * @param CreateRequest $createRequest
  *
  * @return $this|bool|\Illuminate\Http\RedirectResponse
  */
 public function postCreate($forumId, CreateRequest $createRequest)
 {
     // Forum permissions are checked in "CreateRequest"
     if (!$this->guard->check()) {
         $captcha = $this->checkCaptcha();
         if ($captcha !== true) {
             return $captcha;
         }
     }
     $poll = null;
     if ($createRequest->input('add-poll')) {
         $pollCreateRequest = app()->make('MyBB\\Core\\Http\\Requests\\Poll\\CreateRequest');
         $poll = ['question' => $pollCreateRequest->input('question'), 'num_options' => count($pollCreateRequest->options()), 'options' => $pollCreateRequest->options(), 'is_closed' => false, 'is_multiple' => (bool) $pollCreateRequest->input('is_multiple'), 'is_public' => (bool) $pollCreateRequest->input('is_public'), 'end_at' => null, 'max_options' => (int) $pollCreateRequest->input('maxoptions')];
         if ($pollCreateRequest->input('endAt')) {
             $poll['end_at'] = new \DateTime($pollCreateRequest->input('endAt'));
         }
     }
     $topic = $this->topicRepository->create(['title' => $createRequest->input('title'), 'forum_id' => $createRequest->input('forum_id'), 'first_post_id' => 0, 'last_post_id' => 0, 'views' => 0, 'num_posts' => 0, 'content' => $createRequest->input('content'), 'username' => $createRequest->input('username')]);
     if ($topic) {
         if ($poll) {
             $poll['topic_id'] = $topic->id;
             $this->pollRepository->create($poll);
             $this->topicRepository->setHasPoll($topic, true);
         }
         return redirect()->route('topics.show', ['slug' => $topic->slug, 'id' => $topic->id]);
     }
     return redirect()->route('topic.create', ['forumId' => $forumId])->withInput()->withErrors(['content' => trans('errors.error_creating_topic')]);
 }
开发者ID:Adamzynoni,项目名称:mybb2,代码行数:34,代码来源:TopicController.php

示例13: myVote

 /**
  * @return mixed
  */
 public function myVote()
 {
     if (!isset($this->cache['myVote'])) {
         if ($this->guard->check()) {
             $this->cache['myVote'] = $this->pollVoteRepository->findForUserPoll($this->guard->user(), $this->wrappedObject);
         } else {
             $this->cache['myVote'] = null;
         }
     }
     return $this->cache['myVote'];
 }
开发者ID:Adamzynoni,项目名称:mybb2,代码行数:14,代码来源:Poll.php

示例14: login

 /**
  * Return the admin login form.
  *
  * @param LoginFormBuilder $form
  * @param Redirector       $redirect
  * @param Repository       $config
  * @param Guard            $auth
  * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function login(LoginFormBuilder $form, Redirector $redirect, Repository $config, Guard $auth)
 {
     /**
      * If we're already logged in
      * proceed to the dashboard.
      *
      * Replace this later with a
      * configurable landing page.
      */
     if ($auth->check()) {
         return $redirect->to($config->get('anomaly.module.users::paths.home', 'admin/dashboard'));
     }
     return $form->setOption('redirect', $config->get('anomaly.module.users::paths.home', 'admin/dashboard'))->setOption('wrapper_view', 'theme::login')->render();
 }
开发者ID:AkibaTech,项目名称:users-module,代码行数:23,代码来源:LoginController.php

示例15: login

 /**
  * Return the admin login form.
  *
  * @param LoginFormBuilder $form
  * @param Redirector       $redirect
  * @param Repository       $config
  * @param Guard            $auth
  * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function login(NavigationCollection $navigation, LoginFormBuilder $form, Redirector $redirect, Repository $config, Guard $auth)
 {
     /**
      * If we're already logged in
      * proceed to the dashboard.
      *
      * Replace this later with a
      * configurable landing page.
      */
     if ($auth->check() && ($home = $navigation->home())) {
         return $redirect->to($config->get($home->getHref()));
     }
     return $form->setOption('redirect', 'admin')->setOption('wrapper_view', 'theme::login')->render();
 }
开发者ID:jacksun101,项目名称:users-module,代码行数:23,代码来源:LoginController.php


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