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


PHP Request::getPathInfo方法代码示例

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


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

示例1: rate

 public function rate(Request $request, $id)
 {
     $Quote = Quote::withCount(['ratesPlus', 'ratesMinus'])->find($id);
     if (null == $Quote) {
         return response()->json(['status' => 'error', 'message' => trans('app.not_found')]);
     }
     $count = $Quote->rates_plus_count - $Quote->rates_minus_count;
     $voted = $request->cookie(sha1('voted'));
     $voted = null == $voted ? [] : json_decode($voted);
     if (!empty($voted)) {
         if (in_array($id, $voted)) {
             return response()->json(['status' => 'error', 'message' => trans('app.twice_vote'), 'rate' => $count])->cookie(sha1('voted'), json_encode($voted), 60 * 60 * 24 * 120);
         }
     }
     $voted[] = $id;
     $Rate = Rate::where('quote_id', $id)->where('ip', $request->ip())->first();
     if (null != $Rate) {
         return response()->json(['status' => 'error', 'message' => trans('app.twice_vote'), 'rate' => $count])->cookie(sha1('voted'), json_encode($voted), 60 * 60 * 24 * 120);
     }
     $rate = 1 == strpos($request->getPathInfo(), 'omg') ? 1 : (1 == strpos($request->getPathInfo(), 'wtf') ? -1 : 0);
     $Rate = new Rate();
     $Rate->quote_id = $id;
     $Rate->ip = $request->ip();
     $Rate->rate = $rate;
     $Rate->save();
     $Quote->count += $rate;
     $Quote->save();
     return response()->json(['status' => 'ok', 'message' => trans('app.voted'), 'rate' => $count + $rate])->cookie(sha1('voted'), json_encode($voted), 60 * 60 * 24 * 120);
 }
开发者ID:keymic,项目名称:km-qrs,代码行数:29,代码来源:AppController.php

示例2: getFilters

 protected function getFilters()
 {
     $sort_by = $this->request->has('sort-by');
     if (!($param = $this->request->has('sort-by'))) {
         $sort_by = 'all';
     } else {
         $sort_by = strtolower($this->request->get('sort-by'));
     }
     switch ($sort_by) {
         case 'all':
         case 'popularity':
             //            case 'most-recent':
         //            case 'most-recent':
         case 'most-bought':
             //            case 'discounts':
             //DO NOTHING
             break;
         default:
             // Invalid request
             abort(404);
     }
     $filters = [['active' => $sort_by === 'all' ? true : false, 'url' => $this->request->getPathInfo() . '?sort-by=all', 'name' => 'All'], ['active' => $sort_by === 'popularity' ? true : false, 'url' => $this->request->getPathInfo() . '?sort-by=popularity', 'name' => 'Popularity'], ['active' => $sort_by === 'most-bought' ? true : false, 'url' => $this->request->getPathInfo() . '?sort-by=most-bought', 'name' => 'Most Bought']];
     //        $profile = $this->getUser();
     //
     //        if ($profile instanceof Merchant) {
     //
     //
     //        } elseif ($profile instanceof User) {
     //
     //        }
     return $filters;
 }
开发者ID:jobad,项目名称:BazaarCorner,代码行数:32,代码来源:Controller.php

示例3: mock

 public function mock()
 {
     $this->config = $this->getConfigForEndpoint();
     if ($this->config) {
         return $this->getNewResponse();
     }
     throw new EndpointNotConfiguredException(sprintf('%s %s is not configured in config/apimocker.php', $this->request->getMethod(), $this->request->getPathInfo()));
 }
开发者ID:baopham,项目名称:laravel-api-mocker,代码行数:8,代码来源:ApiMockerController.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->is("sitemap") && $request->fullUrl() != '' && $this->auth->guest()) {
         $aSiteMap = \Cache::get('sitemap', []);
         $changefreq = 'always';
         if (!empty($aSiteMap[$request->fullUrl()]['added'])) {
             $aDateDiff = Carbon::createFromTimestamp($aSiteMap[$request->fullUrl()]['added'])->diff(Carbon::now());
             if ($aDateDiff->y > 0) {
                 $changefreq = 'yearly';
             } else {
                 if ($aDateDiff->m > 0) {
                     $changefreq = 'monthly';
                 } else {
                     if ($aDateDiff->d > 6) {
                         $changefreq = 'weekly';
                     } else {
                         if ($aDateDiff->d > 0 && $aDateDiff->d < 7) {
                             $changefreq = 'daily';
                         } else {
                             if ($aDateDiff->h > 0) {
                                 $changefreq = 'hourly';
                             } else {
                                 $changefreq = 'always';
                             }
                         }
                     }
                 }
             }
         }
         $aSiteMap[$request->fullUrl()] = ['added' => time(), 'lastmod' => Carbon::now()->toIso8601String(), 'priority' => 1 - substr_count($request->getPathInfo(), '/') / 10, 'changefreq' => $changefreq];
         \Cache::put('sitemap', $aSiteMap, 2880);
     }
     return $next($request);
 }
开发者ID:Gadurp1,项目名称:KD-2,代码行数:42,代码来源:SiteMap.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->isMethod('get') && !$request->has('PageSpeed') && !$request->is(config('site.admin_path') . '*') && !$request->is('avatar/*') && !$request->is('my/*') && !$request->is('*/login') && !$request->is('*/authorize') && !in_array($request->path(), ['sitemap.xml', 'logout', 'login'])) {
         $aSiteMap = Cache::get('sitemap', []);
         $changefreq = 'always';
         if (!empty($aSiteMap[$request->fullUrl()]['added'])) {
             $aDateDiff = Carbon::createFromTimestamp($aSiteMap[$request->fullUrl()]['added'])->diff(Carbon::now());
             if ($aDateDiff->y > 0) {
                 $changefreq = 'yearly';
             } else {
                 if ($aDateDiff->m > 0) {
                     $changefreq = 'monthly';
                 } else {
                     if ($aDateDiff->d > 6) {
                         $changefreq = 'weekly';
                     } else {
                         if ($aDateDiff->d > 0 && $aDateDiff->d < 7) {
                             $changefreq = 'daily';
                         } else {
                             if ($aDateDiff->h > 0) {
                                 $changefreq = 'hourly';
                             } else {
                                 $changefreq = 'always';
                             }
                         }
                     }
                 }
             }
         }
         $aSiteMap[$request->fullUrl()] = ['added' => time(), 'lastmod' => Carbon::now()->format('Y-m-d\\TH:i:sP'), 'priority' => 1 - substr_count($request->getPathInfo(), '/') / 10, 'changefreq' => $changefreq];
         Cache::forever('sitemap', $aSiteMap);
     }
     return $next($request);
 }
开发者ID:vnsource,项目名称:core,代码行数:42,代码来源:Sitemap.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (auth()->guest() && $request->getPathInfo() != '/backend/login') {
         return redirect('/backend/login');
     }
     return $next($request);
 }
开发者ID:hourglass,项目名称:board,代码行数:14,代码来源:RedirectIfNotAuthenticated.php

示例7: track

 /**
  * Track clicked links and form submissions.
  *
  * @param  Request $request
  * @return void
  */
 public function track(Request $request)
 {
     // Don't track if there is no active experiment.
     if (!$this->session->get('experiment')) {
         return;
     }
     // Since there is an ongoing experiment, increase the pageviews.
     // This will only be incremented once during the whole experiment.
     $this->pageview();
     // Check current and previous urls.
     $root = $request->root();
     $from = ltrim(str_replace($root, '', $request->headers->get('referer')), '/');
     $to = ltrim(str_replace($root, '', $request->getPathInfo()), '/');
     // Don't track refreshes.
     if ($from == $to) {
         return;
     }
     // Because the visitor is viewing a new page, trigger engagement.
     // This will only be incremented once during the whole experiment.
     $this->interact();
     $goals = $this->getGoals();
     // Detect goal completion based on the current url.
     if (in_array($to, $goals) or in_array('/' . $to, $goals)) {
         $this->complete($to);
     }
     // Detect goal completion based on the current route name.
     if ($route = Route::currentRouteName() and in_array($route, $goals)) {
         $this->complete($route);
     }
 }
开发者ID:Raphael-C-Almeida,项目名称:laravel-5-ab,代码行数:36,代码来源:Tester.php

示例8: index

 function index(Request $request, $model)
 {
     $M = $this->models[$model];
     $data = $M::latest()->paginate(20);
     $path = trim($request->getPathInfo(), '/');
     $data->setPath('#!' . $path);
     return \View::make('admin.form.list')->withData($data)->withModel($model);
 }
开发者ID:nisnaker,项目名称:ruyi,代码行数:8,代码来源:FormController.php

示例9: search

 public function search(Request $request, $searchKeywords)
 {
     $xs = new \XS('inspirer');
     $search = $xs->search;
     $page = $request->get('p', 1);
     $page = $page < 1 ? 1 : $page;
     $result = $search->setQuery($searchKeywords)->setLimit(6, ($page - 1) * 5)->search();
     if (count($result) == 0) {
         abort(404);
     }
     $next = count($result) < 6 ? null : $request->getPathInfo() . "?p=" . ($page + 1);
     $prev = $page == 1 ? null : $request->getPathInfo() . "?p=" . ($page - 1);
     $articles = [];
     foreach ($result as $key => $row) {
         $articles[] = (object) array('id' => $row->id, 'name' => $row->name, 'title' => $search->highlight($row->title), 'originalTitle' => $row->title, 'description' => $search->highlight($row->description), 'content' => $search->highlight($row->content));
     }
     return view('page/search', ['articles' => $articles, 'searchKeyword' => $searchKeywords, 'next' => $next, 'prev' => $prev]);
 }
开发者ID:x303597316,项目名称:inspirer,代码行数:18,代码来源:SearchController.php

示例10: handle

 /**
  * Log all api requests
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  *
  * @return mixed
  */
 public function handle(Request $request, \Closure $next)
 {
     try {
         $this->debug($request->getMethod() . ' ' . $request->getPathInfo());
     } catch (\Exception $_ex) {
         //  Ignored.
     }
     return parent::handle($request, $next);
 }
开发者ID:rajeshpillai,项目名称:dfe-common,代码行数:17,代码来源:ApiLogger.php

示例11: findRoute

 protected function findRoute(Request $request, array $routes)
 {
     foreach ($routes as $key => $route) {
         list($method, $domain, $uri) = explode(' ', $key);
         if ($request->getMethod() == $method && $request->getHost() == $domain && trim($request->getPathInfo(), '/') === trim($route['uri'], '/')) {
             return $route;
         }
     }
 }
开发者ID:leloulight,项目名称:laravel_latest,代码行数:9,代码来源:RoutingAdapterStub.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $path = $request->getPathInfo();
     if (strpos($path, '/api/') === 0) {
         \Config::set('session.driver', 'array');
         \Config::set('cookie.driver', 'array');
     }
     return $next($request);
 }
开发者ID:antho-firuze,项目名称:_g.ene.sys_prototype1_,代码行数:16,代码来源:ApiSession.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('login');
         }
     }
     if (\Auth::user()->type != 'user') {
         if (\Auth::user()->type == 'admin') {
             return redirect()->route('admin.home');
         }
         return new Response('Forbidden', 403);
     }
     if (\Auth::user()->birthdate == null && $request->getPathInfo() != '/postaccount' && $request->getPathInfo() != '/newaccount') {
         return redirect()->route('newaccount');
     }
     return $next($request);
 }
开发者ID:charlieboo,项目名称:creatrip,代码行数:27,代码来源:AuthenticateUser.php

示例14: add

 /**
  * Vérification des données utilisateurs avant la création de l'enchère
  *
  * @param Request $request
  * @param int $item_id Identifiant de l'item
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function add(Request $request, $item_id)
 {
     // Après quelques vérifications, l'utilisateur saura s'il a le droit d'enchérir ou non
     $denied = false;
     // On récupère l'ID du formulaire (permettra de savoir à quel formulaire une erreur s'est produite)
     $form_id = $request->input('_form_id', 'default');
     // Si l'utilisateur a supprimé le champ (gg), on essaye de récupérer l'ID dans l'URL
     if ($form_id === null && preg_match('/\\/items/', URL::previous())) {
         $url_items = explode('/', $request->getPathInfo());
         $form_id = 'form_' . array_pop($url_items);
     }
     // Les messages d'erreurs seront désormais spécifiques à un formulaire, et pas tous
     $this->validatesRequestErrorBag = $form_id;
     // Permettra de savoir dans quel formulaire s'est produite l'erreur
     $request->session()->flash('errorBag', $this->validatesRequestErrorBag);
     // On check si l'item existe bien dans la BBD ('Ivre, il enchérit une vente qui n'existe pas, la suite va vous surprendre !)
     $item = Items::get()->where('id', $item_id)->first();
     $min_price = $item->getPrice() + 1;
     // L'enchère n'existe pas
     if ($item === null) {
         $denied = true;
         $request->session()->flash('message', 'danger|Cette enchère n\'existe pas');
         return redirect(route('items'));
     }
     // L'enchère existe, donc on fait quelques tests dessus
     if ($item !== null) {
         // La vente n'a pas encore commencé
         if (strtotime($item->date_end) - time() < 0) {
             $denied = true;
             $request->session()->flash('message', 'danger|L\'enchère n\'a même pas commencé, calmez-vous...');
             // La vente est terminé
         } elseif (strtotime($item->date_start) - time() > 0) {
             $denied = true;
             $request->session()->flash('message', 'danger|L\'enchère est terminée !');
         }
         // L'utilisateur a atteint le nombre maximum de renchère sur cette annonce
         if ($item->getUserCantBid()) {
             $denied = true;
             $request->session()->flash('message', 'danger|Vous avez dépassé les ' . MAX_BID_PER_SALE . ' propositions d\'enchères maximales !');
         }
     }
     // Le vendeur ne peut pas enchérir sa propre annonce...
     if ($item->isSeller()) {
         $denied = true;
         $request->session()->flash('message', 'danger|Il n\'est pas possible d\'enchérir votre annonce..');
     }
     // Pour une quelconque raison, l'utilisateur n'a pas pu enchérir
     if ($denied) {
         return redirect(route('items'));
     }
     // Le prix rentré doit être supérieur à la valeur minimale de l'enchère
     $this->validate($request, ['price' => 'required|numeric|min:' . $min_price], ['price.min' => 'Le prix doit être supérieur à :min €.']);
     return $this->create($request, $item_id);
 }
开发者ID:Kocal,项目名称:IUT-PHP-Le-Chaudron-Baveur,代码行数:61,代码来源:BidsController.php

示例15: isEnabledFor

 /**
  * Shall be throttle limit enabled for given request?
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return bool
  */
 protected function isEnabledFor($request)
 {
     // Limit only POST requests
     if ($request->getMethod() != 'POST') {
         return false;
     }
     // Disable throttle limit for voting
     if (starts_with($request->getPathInfo(), '/ajax/vote/')) {
         return false;
     }
     return true;
 }
开发者ID:vegax87,项目名称:Strimoid,代码行数:19,代码来源:RateLimit.php


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