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


PHP Request::segments方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $uri_segments = $request->segments();
     if (!empty($uri_segments) && in_array("api", $uri_segments)) {
         return $next($request);
     }
     if (\Auth::guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('http://login.' . \Config::get('app.domain') . '/');
         }
     }
     $usuario = \Auth::user();
     if (!empty($usuario)) {
         //Menú de administrador
         if ($usuario->hasRole('administrador')) {
             \Menu::make('menu_lateral', function ($menu) {
                 $menu->add('Inicio', 'inicio');
             });
         }
     } else {
         \Redirect::to('/error500');
     }
     return $next($request);
 }
开发者ID:AndresRojasIsaza,项目名称:Delivery,代码行数:33,代码来源:UsersMidelware.php

示例2: getShareableModel

 /**
  * Fetch shareable model from db based on route params.
  *
  * @param Request $request
  * @return App\Folder | App\File
  */
 private function getShareableModel(Request $request)
 {
     list($route, $type, $share_id, $name) = $request->segments();
     $type = strtolower($type);
     $className = 'App\\' . ucfirst($type);
     return App::make($className)->where('share_id', $share_id)->where('name', urldecode($name))->firstOrFail();
 }
开发者ID:syntropysoftware,项目名称:cryptoffice-frontend,代码行数:13,代码来源:PrerenderIfCrawler.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $requestID = $request->segments()[1];
     if ($requestID != Auth::user()->id) {
         return redirect('profile')->with('danger', 'You do not have access to update this information');
     }
     return $next($request);
 }
开发者ID:samyerkes,项目名称:sweet.com,代码行数:15,代码来源:UserInfo.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $creditcardId = $request->segments()[2];
     $ccUser = CreditCard::find($creditcardId);
     if ($ccUser->user_id != Auth::user()->id) {
         return redirect('profile')->with('danger', 'This credit card is not associated with you.');
     }
     return $next($request);
 }
开发者ID:samyerkes,项目名称:sweet.com,代码行数:16,代码来源:CreditCardUser.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $addressId = $request->segments()[2];
     $addrUser = Address::find($addressId);
     // if ($addrUser->user_id != Auth::user()->id)
     // {
     //     return redirect('profile')->with('danger', 'This address is not associated with you.');
     // }
     return $next($request);
 }
开发者ID:samyerkes,项目名称:sweet.com,代码行数:17,代码来源:AddressUser.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (in_array('admin', $request->segments())) {
         app()->setLocale('backend/vi');
     } elseif ($lang = session()->get('locale')) {
         app()->setLocale($lang);
     } else {
         app()->setLocale(default_lang());
     }
     return $next($request);
 }
开发者ID:JamesNguyen9x,项目名称:vatc,代码行数:18,代码来源:setLocal.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Make sure current locale exists.
     $locale = $request->segment(1);
     if (!array_key_exists($locale, $this->app->config->get('app.locales'))) {
         $segments = $request->segments();
         $segments[0] = $this->app->config->get('app.fallback_locale');
         return $this->redirector->to(implode('/', $segments));
     }
     $this->app->setLocale($locale);
     return $next($request);
 }
开发者ID:sashacitylight,项目名称:sashasite,代码行数:19,代码来源:Language.php

示例8: permissions

 /**
  * Set permissions to be used in the controller.
  *
  * @param  Request  $request
  * @return void
  */
 public function permissions(Request $request)
 {
     $this->lock->setRole(User::$userTypes);
     $user = $this->jwtAuth->user();
     $owner = [User::class, 'userIsOwner', $user, last($request->segments())];
     $this->lock->role(User::USER_TYPE_ADMIN)->permit(['readAll', 'readOne', 'update', 'delete']);
     $this->lock->role(User::USER_TYPE_GUEST)->permit(['readOne', 'update'], [$owner]);
     $this->middleware('permission:readAll', ['only' => 'getAllPaginated']);
     $this->middleware('permission:readOne', ['only' => 'getOne']);
     $this->middleware('permission:update', ['only' => 'patchOne']);
     $this->middleware('permission:delete', ['only' => 'deleteOne']);
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:18,代码来源:UserController.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $uri_segments = $request->segments();
     $subdominio = $request->root();
     $subdominio = str_replace('http://', '', $subdominio);
     $subdominio = explode('.', $subdominio);
     $subdominio = $subdominio['0'];
     if ($subdominio === "api") {
         return $next($request);
     }
     return parent::handle($request, $next);
 }
开发者ID:AndresRojasIsaza,项目名称:Delivery,代码行数:19,代码来源:VerifyCsrfToken.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     // Throw 404 HTTP error if not an Ajax request
     if (!$request->ajax()) {
         $segments = $request->segments();
         $lang = array_shift($segments);
         $url = url() . '/' . $lang . $request->path . '#/' . implode('/', $segments);
         return redirect($url);
     }
     // Process request
     $response = $next($request);
     return $response;
 }
开发者ID:simondubois,项目名称:budget,代码行数:20,代码来源:Ajax.php

示例11: __construct

 public function __construct(Request $request)
 {
     $segments = $request->segments();
     $locales = LaravelLocalization::getSupportedLanguagesKeys();
     $non_locale_route = '';
     $lang = App::getLocale();
     foreach ($segments as $segment) {
         if (!in_array($segment, $locales)) {
             $non_locale_route .= '/' . $segment;
         }
     }
     DEFINED('NON_LOCALE_ROUTE') or DEFINE('NON_LOCALE_ROUTE', trim($non_locale_route, '/'));
     DEFINED('LANG') or DEFINE('LANG', $lang);
 }
开发者ID:NickMomchev,项目名称:bautech,代码行数:14,代码来源:Controller.php

示例12: 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()) {
         $uri_segments = $request->segments();
         $subdominio = $request->root();
         $subdominio = str_replace('http://', '', $subdominio);
         $subdominio = explode('.', $subdominio);
         $subdominio = $subdominio['0'];
         if ($subdominio === "api") {
             return \Response::json(array('success' => false, 'message' => 'No se ha podido iniciar sesión'));
         }
         return redirect()->guest('auth/login');
     }
     return $next($request);
 }
开发者ID:AndresRojasIsaza,项目名称:Delivery,代码行数:22,代码来源:Authenticate.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $segments = $request->segments();
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect($segments[0] . '/admin/login');
         }
     } else {
         $client = \App\Administrator::where('user_id', $request->user()->id)->first();
         if ($client == null) {
             return redirect($segments[0] . '/admin/login')->withInput($request->only('email', 'remember'))->withErrors(['email' => 'You are not a registered admin']);
         }
     }
     return $next($request);
 }
开发者ID:Jemok,项目名称:skoolspace,代码行数:24,代码来源:Administrator.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $segments = $request->segments();
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect($segments[0] . '/login');
         }
     } else {
         $client = \App\Client::where('user_id', $request->user()->id)->first();
         if ($client == null) {
             return redirect($segments[0] . '/patch/' . $request->user()->id);
         }
     }
     return $next($request);
 }
开发者ID:Jemok,项目名称:skoolspace,代码行数:24,代码来源:Client.php

示例15: __construct

 public function __construct(Request $request)
 {
     $segments = $request->segments();
     $locales = LaravelLocalization::getSupportedLanguagesKeys();
     $non_locale_route = '';
     $lang = App::getLocale();
     foreach ($segments as $segment) {
         if (!in_array($segment, $locales)) {
             $non_locale_route .= '/' . $segment;
         }
     }
     DEFINED('NON_LOCALE_ROUTE') or DEFINE('NON_LOCALE_ROUTE', trim($non_locale_route, '/'));
     DEFINED('LANG') or DEFINE('LANG', $lang);
     $categories[1] = ProductCategory::getByBrand(5);
     $categories[2] = ProductCategory::getByBrand(6);
     $categories[3] = ProductCategory::getByBrand(7);
     $this->categories = $categories;
 }
开发者ID:NickMomchev,项目名称:bautech,代码行数:18,代码来源:BaseCatalogController.php


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