/** 方法三:使用 request() 辅助函数来获取,效果同方法二 */ request()->route('param1'); //结果为 1 ,如果不带路由参数名则返回当前的Route对象 request()->route('param2'); //结果为 2 ,如果不带路由参数名则返回当前的Route对象 /** 方法四:使用 Route Facade */ Route::input('param1');...
Laravel 获取路由参数的方式有很多,并且有个小坑,汇总如下。 假设我们设置了一个路由参数: 现在我们访问http://test.dev/1/2 在TestController中: 以上就是 Laravel 获取路由参数的 5 种方法。
request()->route('param1'); //结果为 1 ,如果不带路由参数名则返回当前的Route对象 request()->route('param2'); //结果为 2 ,如果不带路由参数名则返回当前的Route对象 /** * 方法四:使用 Route Facade */ \Route::input('param1'); //结果为 1 ,该方法必须带路由参数名 \Route::input('pa...
After the route is accessed, we create a log of the visit along with the date the route was accessed. 使用route group When creating a web app, we may find a few routes that need the same URL prefix or filter. Using Laravel's route groups, we can easily apply these to multiple routes...
Laravel 获取 Route Parameters (路由参数) 的 5 种方法 Laravel 获取路由参数的方式有很多,并且有个小坑,汇总如下。 假设我们设置了一个路由参数: 现在我们访问 http://test.dev/1/2 在TestController 中: 以上就是 Laravel 获取路由参数的 5 种方法。
To generate a URL to this route, you may use the route helper like so:1echo route('post.show', ['post' => 1]); 2 3// http://example.com/post/1Of course, the route helper may also be used to generate URLs for routes with multiple parameters:1Route::get('/post/{post}/...
1Route::view('/welcome', 'welcome'); 2 3Route::view('/welcome', 'welcome', ['name' => 'Taylor']);When using route parameters in view routes, the following parameters are reserved by Laravel and cannot be used: view, data, status, and headers....
这是route助手的签名: function route($name, $parameters = [], $absolute = true) 您应该将任何查询参数添加到数组中,或者将参数传递给route助手: route('orders.paym...
Route::view('/welcome', 'welcome');Route::view('/welcome', 'welcome', ['name' => 'Taylor']);备注 When using route parameters in view routes, the following parameters are reserved by Laravel and cannot be used: view, data, status, and headers....
To generate a URL to this route, you may use the route helper like so:1echo route('post.show', ['post' => 1]); 2 3// http://example.com/post/1Of course, the route helper may also be used to generate URLs for routes with multiple parameters:1Route::get('/post/{post}/...