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


PHP Router::pattern方法代碼示例

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


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

示例1: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('id', '[0-9]+');
     $router->pattern('slug', '[a-zA-Z0-9\\-]+');
     $router->pattern('code', '[a-zA-Z0-9]+');
     parent::boot($router);
 }
開發者ID:VisualAppeal,項目名稱:stock,代碼行數:13,代碼來源: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->pattern('user', '[0-9]+');
     $router->pattern('id', '[0-9]+');
     parent::boot($router);
 }
開發者ID:phumaster,項目名稱:uploadImage,代碼行數:13,代碼來源:RouteServiceProvider.php

示例3: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('id', '[0-9]+');
     $router->pattern('letter', '[A-Za-z]+');
     parent::boot($router);
     //
 }
開發者ID:nameNotNull,項目名稱:laravelapp5.0.2,代碼行數:13,代碼來源:RouteServiceProvider.php

示例4: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('id', '[0-9]+');
     $router->pattern('step', '(clone|install|activate|purge)');
     $router->model('log', 'REBELinBLUE\\Deployer\\ServerLog');
     parent::boot($router);
 }
開發者ID:arasmit2453,項目名稱:deployer,代碼行數:13,代碼來源:RouteServiceProvider.php

示例5: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('id', '[0-9]+');
     // Should handle 32n33-sss-img-dd.png exception
     $router->pattern('image', '(?P<parent>[0-9n]{2,5}-[\\pL-\\pN\\._-]+)-(?P<suffix>img-[0-9]{2}.png)');
     parent::boot($router);
 }
開發者ID:hongpyo,項目名稱:l5essential,代碼行數:13,代碼來源:RouteServiceProvider.php

示例6: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param Router $router
  */
 public function boot(Router $router)
 {
     $router->pattern('id', '[0-9]+');
     $router->pattern('step', '(clone|install|activate|purge)');
     $router->model('log', ServerLog::class);
     parent::boot($router);
 }
開發者ID:rebelinblue,項目名稱:deployer,代碼行數:12,代碼來源:RouteServiceProvider.php

示例7: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('zipcode', '\\d{5}([\\-]?\\d{4})?');
     $router->pattern('state', '[a-zA-Z]{2}');
     $router->pattern('district', '\\d{1,3}');
     $router->pattern('lat', '^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)');
     $router->pattern('lng', '[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)');
     parent::boot($router);
 }
開發者ID:edfialk,項目名稱:ContactMyReps,代碼行數:15,代碼來源:RouteServiceProvider.php

示例8: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     // Sets up our routing tokens.
     $router->pattern('board', Board::URI_PATTERN);
     $router->pattern('id', '[1-9]\\d*');
     $router->model('ban', '\\App\\Ban');
     $router->model('board', '\\App\\Board');
     $router->model('post', '\\App\\Post');
     $router->model('report', '\\App\\Report');
     $router->model('role', '\\App\\Role');
     $router->bind('user', function ($value, $route) {
         if (is_numeric($value)) {
             return \App\User::find($value);
         } else {
             if (preg_match('/^[a-z0-9]{1,64}\\.(?P<id>\\d+)$/i', $value, $matches)) {
                 return \App\User::find($matches['id']);
             }
         }
     });
     $router->bind('role', function ($value, $route) {
         if (is_numeric($value)) {
             return \App\Role::find($value);
         } else {
             if (preg_match('/^[a-z0-9]{1,64}\\.(?P<id>\\d+)$/i', $value, $matches)) {
                 return \App\Role::find($matches['id']);
             }
         }
     });
     $router->bind('post_id', function ($value, $route) {
         $board = $route->getParameter('board');
         if (is_numeric($value) && $board instanceof Board) {
             return $board->getThreadByBoardId($value);
         }
     });
     // Binds a matched instance of a {board} as a singleton instance.
     $router->matched(function ($route, $request) {
         // Binds the board to the application if it exists.
         $board = $route->getParameter('board');
         if ($board instanceof Board && $board->exists) {
             $board->applicationSingleton = true;
             //$this->app->instance("\App\Board", $board);
             $this->app->singleton("\\App\\Board", function ($app) use($board) {
                 return $board->load(['assets', 'settings']);
             });
         }
         // Binds the post to the application if it exists.
         $post = $route->getParameter('post_id');
         if ($post instanceof Post && $post->exists) {
             $route->setParameter('post', $post);
             //$this->app->instance("\App\Post", $post);
             $this->app->singleton("\\App\\Post", function ($app) use($post) {
                 return $post;
             });
         }
     });
     parent::boot($router);
 }
開發者ID:JEWSbreaking8chan,項目名稱:infinity-next,代碼行數:63,代碼來源:RouteServiceProvider.php

示例9: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param \Illuminate\Routing\Router $router
  *
  * @return void
  */
 public function boot(Router $router)
 {
     //
     $router->pattern('owner', '[a-zA-Z.0-9_\\-]+');
     $router->pattern('project', '[a-zA-Z.0-9_\\-]+');
     $router->pattern('commitishPath', '.+');
     $router->pattern('commit', '[a-f0-9^]+');
     parent::boot($router);
     $this->registerBindings();
 }
開發者ID:gitaminhq,項目名稱:gitamin,代碼行數:17,代碼來源:RouteServiceProvider.php

示例10: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     $router->pattern('id', '[a-zA-Z0-9]+');
     // Every parametters have the name is 'id' are checked before to action in controller
     parent::boot($router);
 }
開發者ID:quanit94,項目名稱:Aiko-web-update,代碼行數:13,代碼來源:RouteServiceProvider.php

示例11: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('board', Board::URI_PATTERN);
     $router->model('board', 'App\\Board');
     $router->model('role', 'App\\Role');
     parent::boot($router);
 }
開發者ID:Ryangr0,項目名稱:infinity-next,代碼行數:13,代碼來源:RouteServiceProvider.php

示例12: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('artist', '[0-9]+');
     $router->pattern('studio', '[-\\w]+');
     $router->pattern('event', '[0-9]+');
     $router->pattern('piece', '[0-9]+');
     $router->pattern('photo', '[0-9]+');
     parent::boot($router);
     $router->model('artist', 'App\\Artist');
     $router->model('piece', 'App\\Piece');
     $router->model('photo', 'App\\Photo');
     $router->bind('studio', function ($slug) {
         return Studio::where('slug', $slug)->firstOrFail();
     });
     $router->model('event', 'App\\Event');
 }
開發者ID:evendev,項目名稱:paintstudio,代碼行數:22,代碼來源:RouteServiceProvider.php

示例13: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     /**
      * Username must be Alphanumeric
      */
     $router->pattern('username', '[0-9a-zA-Z]+');
     parent::boot($router);
 }
開發者ID:Groopy,項目名稱:groopyio,代碼行數:14,代碼來源:RouteServiceProvider.php

示例14: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->model('user', 'Coyote\\User');
     $router->model('post', 'Coyote\\Post');
     $router->model('topic', 'Coyote\\Topic');
     $router->pattern('id', '[0-9]+');
     $router->pattern('forum', '[A-Za-z\\_\\/]+');
     $router->pattern('tag', '([\\p{L}\\p{Mn}0-9\\._+-]+)');
     $router->bind('forum', function ($path) {
         $result = \Coyote\Forum::where('path', $path)->first();
         if (!$result) {
             abort(404);
         }
         return $result;
     });
     parent::boot($router);
 }
開發者ID:furious-programming,項目名稱:coyote,代碼行數:23,代碼來源:RouteServiceProvider.php

示例15: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->pattern('user', '[0-9]+');
     $router->bind('user', function ($value) {
         return User::where('id', $value)->limit(1)->first();
     });
     parent::boot($router);
 }
開發者ID:AdrianoBiolchi,項目名稱:lab-painel-defender,代碼行數:14,代碼來源:RouteServiceProvider.php


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