You may constrain the format of your route parameters using thewheremethod on a route instance. Thewheremethod accepts the name of the parameter and a regular expression defining how the parameter should be constrained: 你可能要限制参数的格式,用route实例的where方法,where方法接受参数名和正则表达式定...
Illuminate \Routing\RouteRegistrar这三个类在IOC容器初始化以及内核启动的过程中实现;后者提供请求的url匹配与参数绑定服务,主要由 Illuminate\Routing\RouteCollection、 Illuminate\Routing\Route、 Illuminate\Routing\Router、Symfony\Routing\RouteCompiler和Illuminate\Routing\RouteParameterBinder这几个类在内核处理请求的...
Route::redirect('/here', '/there'); By default, Route::redirect returns a 302 status code. You may customize the status code using the optional third parameter:Route::redirect('/here', '/there', 301); You may use the Route::permanentRedirect method to return a 301 status code:...
1Route::get('user/{name?}', function($name = null) 2{ 3 return $name; 4});Optional Route Parameters With Default Value1Route::get('user/{name?}', function($name = 'John') 2{ 3 return $name; 4});Regular Expression Parameter Constraints1Route::get('user/{name}', function($...
3Route::get('user/{id}',function($id) 4{ 5//Only called if {id} is numeric. 6}); Accessing A Route Parameter Value If you need to access a route parameter value outside of a route, you may use theRoute::inputmethod: 1Route::filter('foo',function() ...
在下面的代码示例中,第一个参数(parameter)是你“注册”的路由(route),第二个参数是这个路由将要触发的函数(function),函数中包含了应用逻辑。定义路由时不需要开头的斜线(front-slash),唯一的例外是默认路由(default route)只包含一个斜线(front-slash)。
Route::redirect('/here', '/there'); By default, Route::redirect returns a 302 status code. You may customize the status code using the optional third parameter:Route::redirect('/here', '/there', 301); Or, you may use the Route::permanentRedirect method to return a 301 status code:...
=> false" * 'only' => Only "'laroute' => true" routes * 'force' => All routes, ignored "laroute" route parameter */ 'filter' => 'all', /* * Action Namespace * * Set here your controller namespace (see RouteServiceProvider -> $namespace) for cleaner action calls * e.g. ...
('admin/advanced*','owner');// optionally the second parameter can be an array of permissions or roles// user would need to match all roles or permissions for that routeEntrust::routeNeedsPermission('admin/post*',array('create-post','edit-comment')); Entrust::routeNeedsRole('admin/...
Optional Parameters Occasionally you may need to specify a route parameter, but make the presence of that route parameter optional. You may do so by placing a ? mark after the parameter name. Make sure to give the route's corresponding variable a default value: Route::get('user/{name?}'...