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


PHP Router::when方法代碼示例

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


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

示例1: map

 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function map(Router $router)
 {
     $router->when('admin/contacts*', 'AdminRole');
     $router->bind('contact', function ($value) {
         return Contact::where('id', $value)->first();
     });
     /**
      * API routes
      */
     $router->group(['namespace' => $this->namespace, 'prefix' => 'api'], function ($router) {
         $router->post('contacts/batchUpdate', 'ApiContactsController@batchUpdate');
         $router->post('contacts/batchDelete', 'ApiContactsController@batchDelete');
         $router->post('contacts/setOrder', 'ApiContactsController@setOrder');
         $router->resource('contacts', 'ApiContactsController');
     });
     /**
      * Admin routes
      */
     $router->group(['namespace' => $this->namespace, 'prefix' => 'admin', 'middleware' => ['auth']], function ($router) {
         //List Contact
         $router->get('contacts', ['as' => 'contacts', 'uses' => 'AdminContactsController@getIndex', 'permission' => 'contacts_manage']);
         //Create Contact
         $router->get('contacts/create', ['as' => 'create_contacts', 'uses' => 'AdminContactsController@getCreate', 'permission' => 'contacts_manage']);
         $router->post('contacts', ['as' => 'create_contacts', 'uses' => 'AdminContactsController@postCreate', 'permission' => 'contacts_manage']);
         //Edit Contact
         $router->get('contacts/{id}/edit', ['as' => 'edit', 'uses' => 'AdminContactsController@getEdit', 'permission' => 'contacts_manage']);
         $router->post('contacts/{id}', ['uses' => 'AdminContactsController@postEdit', 'permission' => 'contacts_manage']);
         $router->get('contacts/export', ['uses' => 'AdminContactsController@export', 'permission' => 'contacts_manage']);
         $router->resource('admin/contacts', 'AdminContactsController');
     });
 }
開發者ID:khaledof,項目名稱:brikaCms,代碼行數:37,代碼來源:RouteServiceProvider.php

示例2: when

 /**
  * Register a pattern-based filter with the router.
  *
  * @param string $pattern
  * @param string $name
  * @param array|null $methods
  * @return void 
  * @deprecated since version 5.1.
  * @static 
  */
 public static function when($pattern, $name, $methods = null)
 {
     \Illuminate\Routing\Router::when($pattern, $name, $methods);
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:14,代碼來源:_ide_helper.php

示例3: when

 /**
  * Register a pattern-based filter with the router.
  *
  * @param string     $pattern
  * @param string     $name
  * @param array|null $methods
  *
  * @static
  */
 public static function when($pattern, $name, $methods = NULL)
 {
     return \Illuminate\Routing\Router::when($pattern, $name, $methods);
 }
開發者ID:netxinyi,項目名稱:laravel-code-tips,代碼行數:13,代碼來源:Route.php


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