當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::is方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\Request::is方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::is方法的具體用法?PHP Request::is怎麽用?PHP Request::is使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\Request的用法示例。


在下文中一共展示了Request::is方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Request::is('login/*')) {
         return $next($request)->header('Access-Control-Allow-Origin', '*')->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, X-Auth-Token');
     }
     return $next($request);
 }
開發者ID:JolitaGrazyte,項目名稱:lockedornot,代碼行數:14,代碼來源:Cors.php

示例2: whitelisted

 static function whitelisted()
 {
     // Detect API Request
     //
     if (Input::get('api_key') && Input::get('user_uid')) {
         if (Config::get('app.api_key') == Input::get('api_key')) {
             if (!User::getIndex(Input::get('user_uid'))) {
                 return false;
             }
             Session::set('user_uid', Input::get('user_uid'));
             return true;
         }
         return false;
     }
     // Detect Whitelisted Route
     //
     foreach (Config::get('app.whitelist') as $pattern) {
         if (is_array($pattern)) {
             if (Request::is(key($pattern))) {
                 return in_array(self::method(), current($pattern));
             }
         } else {
             if (Request::is($pattern)) {
                 return true;
             }
         }
     }
     return false;
 }
開發者ID:pombredanne,項目名稱:open-swamp,代碼行數:29,代碼來源:FiltersHelper.php

示例3: handle

 /**
  * Handle the specified event.
  */
 public function handle()
 {
     $isOnAdmin = Request::is('admin') || Request::is('admin/*');
     if (!$isOnAdmin) {
         Visitor::track();
     }
 }
開發者ID:mrzeta,項目名稱:admin,代碼行數:10,代碼來源:VisitorObserver.php

示例4: build

 /**
  * Build a navigation menu from an array with the following structure: <br/>
  * $navbar = array( <br/>
  *		['url'=>'url',           'textkey'=>'public.title', 'nopattern' => true ], <br/>
  *		['url'=>'url/products',  'textkey'=>'public.products.title' ], <br/>
  *		['url'=>'url/clients',   'textkey'=>'public.clients.title', 'icon' => 'fa-users' ], <br/>
  *);
  */
 public static function build(array $_menu, $_currentLocale = '', $_addItemClass = '')
 {
     $str = '';
     foreach ($_menu as $key => $option) {
         $icon = isset($option['icon']) ? '<i class="fa ' . $option['icon'] . ' fa-fw"></i> ' : '';
         if (isset($option['divider'])) {
             $str .= '<li class="divider"></li>';
         } else {
             if (isset($option['submenu'])) {
                 $requestPattern = $_currentLocale . ($option['url'] == '' ? '' : '/' . $option['url'] . '*');
                 $isActive = '';
                 $isOpenned = '';
                 if (Request::is($requestPattern)) {
                     $isActive = ' active';
                     $isOpenned = ' in';
                 }
                 $str .= '<li class="' . $_addItemClass . ' list-toggle' . $isActive . '">' . '<a class="accordion-toggle" href="#collapse-' . $key . '" data-toggle="collapse">' . $icon . trans($option['textkey']) . '</a>' . '<ul id="collapse-' . $key . '" class="collapse' . $isOpenned . '">' . self::build($option['submenu'], $_currentLocale) . '</ul>' . '</li>';
             } else {
                 $submenusPattern = isset($option['nopattern']) ? '' : '*';
                 $requestPattern = $_currentLocale . ($option['url'] == '' ? '' : '/' . $option['url'] . $submenusPattern);
                 //$requestPattern = $_currentLocale . $option['url'] . $submenusPattern;
                 $isActive = \Request::is($requestPattern) ? ' active' : '';
                 $str .= '<li class="' . $_addItemClass . $isActive . '">' . '<a href="' . \URL::to($option['url']) . '">' . $icon . trans($option['textkey']) . '</a>' . '</li>';
             }
         }
     }
     return $str;
 }
開發者ID:ajgallego,項目名稱:laravel-helpers,代碼行數:36,代碼來源:HelpMenu.php

示例5: e

 /**
  * Set active class if request is in path.
  *
  * @param string $path
  * @param array  $classes
  * @param string $active
  *
  * @return string
  */
 function set_active($path, array $classes = [], $active = 'active')
 {
     if (Request::is($path)) {
         $classes[] = $active;
     }
     $class = e(implode(' ', $classes));
     return empty($classes) ? '' : "class=\"{$class}\"";
 }
開發者ID:nguyentamvinhlong,項目名稱:Cachet,代碼行數:17,代碼來源:helpers.php

示例6: foreach

 /**
  * Set active to specified selector.
  *
  * @param array|string $paths
  * @param string       $class
  *
  * @return string
  */
 function set_active($paths, $class = 'active')
 {
     foreach ((array) $paths as $path) {
         if (Request::is($path)) {
             return $class;
         }
     }
 }
開發者ID:aguaragazu,項目名稱:LaravelStart,代碼行數:16,代碼來源:helpers.php

示例7: register

 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     if (!Request::is('file/*')) {
         $this->loadViewsFrom(__DIR__ . '/../../views', $this->packageName);
         $this->app->register(\Phileserver\Core\Providers\EventServiceProvider::class);
         $this->app->routeMiddleware(['token' => 'Phileserver\\Core\\Http\\Middleware\\CheckToken']);
         $this->registerCommands();
     }
 }
開發者ID:phileserver,項目名稱:core,代碼行數:14,代碼來源:PhileserverServiceProvider.php

示例8: check

 public function check($routes = [], $class = 'active')
 {
     foreach ($routes as $route) {
         if (Request::is($route)) {
             return $class;
         }
     }
     return '';
 }
開發者ID:kilrizzy,項目名稱:active-menu,代碼行數:9,代碼來源:ActiveMenu.php

示例9: __construct

 /**
  * @param ImageUploader $uploader
  */
 public function __construct(ImageUploader $uploader)
 {
     $this->uploader = $uploader;
     if (Request::is('admin/pages')) {
         $this->articles = App::make(PagesRepository::className());
     } else {
         $this->articles = App::make(ArticleRepository::className());
     }
 }
開發者ID:arwinjp,項目名稱:ODTS,代碼行數:12,代碼來源:ArticlesController.php

示例10: isActive

 /**
  * @param Item $item
  *
  * @return bool
  */
 public function isActive(Item $item)
 {
     // Check if one of the children is active
     foreach ($item->getItems() as $item) {
         if ($this->isActive($item)) {
             return true;
         }
     }
     // Custom set active path
     if ($path = $item->getActiveWhen()) {
         return Request::is($path);
     }
     $path = ltrim(str_replace(url('/'), '', $item->getUrl()), '/');
     return Request::is($path, $path . '/*');
 }
開發者ID:fordongu,項目名稱:maigc-menubar,代碼行數:20,代碼來源:ActiveStateChecker.php

示例11: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     \HTML::macro('activeClass', function ($path, $active = 'active') {
         if (Request::is($path . "*")) {
             return $active;
         }
         return '';
     });
     \Validator::resolver(function ($translator, $data, $rules, $messages) {
         return new CustomValidator($translator, $data, $rules, $messages);
     });
     \Blade::extend(function ($value) {
         return preg_replace('/\\@define(.+)/', '<?php ${1}; ?>', $value);
     });
 }
開發者ID:GMSteuart,項目名稱:PandaLove,代碼行數:20,代碼來源:AppServiceProvider.php

示例12: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     if (collect(Analytics::find(1))->contains(1)) {
         view()->share('analytics', Analytics::find(1));
     }
     if (collect(Configuracao::find(1))->contains(1)) {
         view()->share('confsite', Configuracao::find(1));
     }
     if (collect(Comentarios::where('id_status_comentario', 1)->get())->count()) {
         view()->share('comments', collect(Comentarios::where('id_status_comentario', 1)->get())->count());
     }
     view()->share('sobre', Sobres::findOrFail(1));
     if (Request::is('blog') or Request::is('blog/*')) {
         view()->share('categorias', Categoria::where('id_tipo_categoria', 3)->get());
         view()->share('ultimas', collect(Noticia::todas())->take(4));
     }
     if (Request::is('admin') or Request::is('admin/*')) {
         view()->share('ajuda', Helps::all());
     }
 }
開發者ID:safaricco,項目名稱:admfw,代碼行數:25,代碼來源:AppServiceProvider.php

示例13: handle

 /**
  * @param          $request
  * @param \Closure $next
  * @param array    $permissions
  *
  * @see http://laravel.com/docs/5.1/middleware#middleware-parameters
  *
  * @return \Illuminate\Http\RedirectResponse|\Laravel\Lumen\Http\Redirector
  */
 public function handle($request, Closure $next, $permissions = [])
 {
     if (!is_array($permissions)) {
         $permissions = [$permissions];
     }
     // no permission required
     if (empty($permissions)) {
         return $next($request);
     }
     Clockwork::startEvent('acl.middleware', 'Acl middleware.');
     foreach ($permissions as $permission) {
         if (!Acl::isUserAllow(Auth::user(), $permission)) {
             Clockwork::stopEvent('acl.middleware');
             if (Request::is('api*')) {
                 return response('Not authorized', 403);
             } else {
                 return view('auth.notAuthorized');
             }
         }
     }
     Clockwork::stopEvent('acl.middleware');
     return $next($request);
 }
開發者ID:ndrx-io,項目名稱:elude,代碼行數:32,代碼來源:AclMiddleware.php

示例14: isProfilerCall

 protected function isProfilerCall()
 {
     return Request::is('api/profiler/profiles*');
 }
開發者ID:ndrx-io,項目名稱:profiler-laravel,代碼行數:4,代碼來源:LaravelProfilerServiceProvider.php

示例15: setActive

 public static function setActive($path, $active = 'active')
 {
     return Request::is($path) ? $active : '';
 }
開發者ID:RaymondWilkinson,項目名稱:AdminPanel,代碼行數:4,代碼來源:Helper.php


注:本文中的Illuminate\Support\Facades\Request::is方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。