當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。