Thursday, March 16, 2017

How to add string id in url ? Laravel 5.3

My link href on the view is like this :

<a href="" class="btn btn-default">
    <span class="fa fa-eye"></span> 
</a>

My routes is like this :

Route::get('message/inbox/detail/{id}', ['as'=>'message.inbox.detail.id','uses'=>'MessageController@detail']);

The result of url is like this :

http://myshop.dev/message/inbox/detail/58cadfba607a1d2ac4000254

My controller is like this :

public function detail($id)
{
    dd($id);
}

If like that, I success get value of id

But I want change the result of url like this :

http://myshop.dev/message/inbox/detail/id/58cadfba607a1d2ac4000254

I want change the url like that, because on the controller I want get request like this :

public function detail($id, Request $request)
{
    dd($id, $request);
}

How can I do it?



via samuel toh

Advertisement