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


PHP Router::filter方法代码示例

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


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

示例1: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     /*
     |--------------------------------------------------------------------------
     | Authentication Filters
     |--------------------------------------------------------------------------
     |
     | The following filters are used to verify that the user of the current
     | session is logged into this application. The "basic" filter easily
     | integrates HTTP Basic authentication for quick, simple checking.
     |
     */
     $router->filter('auth.basic', function () {
         return Auth::basic();
     });
     /*
     |--------------------------------------------------------------------------
     | Guest Filter
     |--------------------------------------------------------------------------
     |
     | The "guest" filter is the counterpart of the authentication filters as
     | it simply checks that the current user is not logged in. A redirect
     | response will be issued if they are, which you may freely change.
     |
     */
     $router->filter('guest', function () {
         if (Auth::check()) {
             return Redirect::to('/');
         }
     });
     parent::boot($router);
 }
开发者ID:programadorjff,项目名称:ioltest,代码行数:39,代码来源:RouteServiceProvider.php

示例2: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->filter('auth', function () {
         if (Auth::guest()) {
             if (Request::ajax()) {
                 return Response::make('Unauthorized', 401);
             } else {
                 return Redirect::guest('/');
             }
         }
     });
     $router->filter('auth.basic', function () {
         return Auth::basic();
     });
     $router->filter('guest', function () {
         if (Auth::check()) {
             return Redirect::to('/');
         }
     });
     $router->filter('admin', function () {
         if (Auth::check()) {
             if (Auth::user()->email != "ceesco53@gmail.com") {
                 return Redirect::to('/');
             }
         } else {
             return Redirect::to('/');
         }
     });
     parent::boot($router);
 }
开发者ID:siparker,项目名称:ribbbon,代码行数:36,代码来源:RouteServiceProvider.php

示例3: map

 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function map(Router $router)
 {
     $router->group(['namespace' => $this->namespace], function ($router) {
         require app_path('Http/routes.php');
     });
     $router->filter("userauth", function () {
         if (!Auth::user()->check()) {
             return redirect("");
         }
     });
     $router->filter("organizationauth", function () {
         if (!Auth::organization()->check()) {
             return redirect("/organizations/login");
         }
     });
 }
开发者ID:sas48mouad,项目名称:mouad,代码行数:22,代码来源:RouteServiceProvider.php

示例4: map

 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function map(Router $router)
 {
     $router->group(['namespace' => $this->namespace], function ($router) {
         require app_path('Http/routes.php');
     });
     $router->filter('authuser', function () {
         if (!\Auth::check()) {
             return redirect()->guest('login');
         }
     });
     $router->filter('filtername', function ($route, $request, $value) {
         $array = explode('-', $value);
         // use - for delimiter
         return $array;
         // do whatever here
     });
 }
开发者ID:VictorOverX,项目名称:vLine-CMS,代码行数:23,代码来源:RouteServiceProvider.php

示例5: setupFilters

 /**
  * Setup the filters.
  *
  * @param \Illuminate\Routing\Router        $router
  * @param \GrahamCampbell\Throttle\Throttle $throttle
  *
  * @return void
  */
 protected function setupFilters(Router $router, Throttle $throttle)
 {
     $router->filter('throttle', function ($route, $request, $limit = 10, $time = 60) use($throttle) {
         if (!$throttle->attempt($request, $limit, $time)) {
             throw new TooManyRequestsHttpException($time * 60, 'Rate limit exceed.');
         }
     });
 }
开发者ID:xhulioh25,项目名称:wiki,代码行数:16,代码来源:ThrottleServiceProvider.php

示例6: register

 public function register(Router $router, Resolver $resolver)
 {
     $reflection = new ReflectionMethodsFilter($this);
     foreach ($methods = $reflection->filterPrefix($this->getPrefix()) as $method) {
         $router->filter($method, $resolver->methodToClosure($this, $method));
     }
     $this->registered = true;
 }
开发者ID:laravel-commode,项目名称:filters,代码行数:8,代码来源:AbstractFilterGroup.php

示例7: registerFilters

 /**
  * Register the filters.
  *
  * @param  Router $router
  * @return void
  */
 public function registerFilters(Router $router)
 {
     foreach ($this->filters as $module => $filters) {
         foreach ($filters as $name => $filter) {
             $class = "Modules\\{$module}\\Http\\Filters\\{$filter}";
             $router->filter($name, $class);
         }
     }
 }
开发者ID:optik,项目名称:Blog,代码行数:15,代码来源:BlogServiceProvider.php

示例8: map

 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function map(Router $router)
 {
     $router->group(['namespace' => $this->namespace], function ($router) {
         require app_path('Http/routes.php');
     });
     $router->filter('notlogin', function () {
         if (auth()->user()) {
             return redirect(athr . '/categories');
         }
     });
 }
开发者ID:ewaschool,项目名称:dirassa,代码行数:17,代码来源:RouteServiceProvider.php

示例9: registerRouteFilters

 /**
  * Register route filters.
  *
  * @param  \Illuminate\Routing\Router  $router
  *
  * @return void
  */
 protected function registerRouteFilters(Router $router)
 {
     foreach ((array) $this->before as $before) {
         $router->before($before);
     }
     foreach ((array) $this->after as $after) {
         $router->after($after);
     }
     foreach ((array) $this->filters as $name => $filter) {
         $router->filter($name, $filter);
     }
 }
开发者ID:DavidIWilson,项目名称:site1,代码行数:19,代码来源:FilterProviderTrait.php

示例10: filter

 /**
  * Register a new filter with the router.
  *
  * @param string $name
  * @param string|callable $callback
  * @return void 
  * @deprecated since version 5.1.
  * @static 
  */
 public static function filter($name, $callback)
 {
     \Illuminate\Routing\Router::filter($name, $callback);
 }
开发者ID:satriashp,项目名称:tour,代码行数:13,代码来源:_ide_helper.php


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