本文整理汇总了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');
});
}
示例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);
}
示例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);
}