How to use the request route parameter in Laravel 5 form request?
That's very simple, just use the route()
method. Assuming your route parameter is called id
:
public function authorize(){ $id = $this->route('id');}
You can accessing a Route parameter Value via Illuminate\Http\Request instance
public function destroy($id, DeletePivotRequest $request){ if ($request->route('id')) { // } Resource::findOrFail($id);}
Depending on how you defined the parameter in your routes.
For my case below, it would be: 'user'
not 'id'
$id = $this->route('user');