My link href on the view is like this :
<a href="{{ route('message.inbox.detail.id', ['id' => $message->id]) }}" class="btn btn-default">
<span class="fa fa-eye"></span> {{ trans('button.view') }}
</a>
My routes is like this :
Route::get('message/inbox/detail/id/{id}', ['as'=>'message.inbox.detail.id','uses'=>'MessageController@detail']);
When clicked, the url display like this :
http://myshop.dev/message/inbox/detail/id/58cadfba607a1d2ac4000254
I want get id with Request $request
On the controller, I try like this :
public function detail(Request $request)
{
dd($request->input('id'));
}
The result : null
How can I solve it?
input() is a method of the Laravel Request class that is extending Symfony Request class, and it supports dot notation to access nested data (like $name = $request->input('products.0.name') ).
You can pass query string to URL in laravel using named route and controller action. You can pass query string as comma separated array to named route and controller action and redirect to URL.
Method 1: $request->route('parameter_name') We can access route parameters in two ways. One way is by using $request->route('parameter_name') ., where parameter_name refers to what we called the parameter in the route.
You can get it like this
$request->route('id')
Inside request class you can access it this way
$this->route('id')
I usually use it when I'm validating field to make sure it's unique, and I need to exclude model by ID when I'm doing update
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With