在 class 中获取扩展 Request 的路由参数
Getting a route parameter in class that extends Request
假设我有一条路线:
Route::get('.../{abc}/...', [
'uses' => 'API\SomeApiController@progress'
]);
SomeApiController::progress()
方法获取对象 ApiRequest
作为参数:
public function progress(ApiRequest $request, $abc)
如何在 ApiRequest::authorize()
方法中获取 abc
的值?
在请求对象中,使用 route
方法:
$abc = $this->route('abc');
假设我有一条路线:
Route::get('.../{abc}/...', [
'uses' => 'API\SomeApiController@progress'
]);
SomeApiController::progress()
方法获取对象 ApiRequest
作为参数:
public function progress(ApiRequest $request, $abc)
如何在 ApiRequest::authorize()
方法中获取 abc
的值?
在请求对象中,使用 route
方法:
$abc = $this->route('abc');