Suppose the route is like this:
Route::get('messages/{messages}', ['as' => 'messages.show', 'uses' => 'MessagesController@show']);
So, when we will create an URL using URL helper of Laravel,
{{ route('messages.show', 12) }}
will display example.com/messages/12
.
This is correct. Let's have some hash in the URL.
{{ route('messages.show', [12, '#reply_23']) }}
This will display example.com/messages/12#reply_23
.
This looks good. Now let's add some query strings instead of the hash.
{{ route('messages.show', [12, 'ref=email']) }}
This will display example.com/messages/12?ref=email
. This looks cool.
Now add both query string and hash.
{{ route('messages.show', [12, 'ref=email', '#reply_23']) }}
Now this will display example.com/messages/12?ref=email&#reply_23
. This looks little ugly because of the &
in the URL. However it's not creating a lot of problem, I would like to get a clean URL like example.com/messages/12?ref=email#reply_23
. Is there a way to get rid of the unnecessary &
in the URL?
Edit: There is a workaround, but I am looking for a solid answer.
<a href="{{ route('messages.show', [12, 'ref=email']) }}#reply_23">Link to view on website</a>