Is there a possibility to get the part of url, that is defined in route?
For example with this route:
Route::get('/editor/{id}', 'EditorController@editor')->name('editorNew');
after using mentioned functionality, let’s say route_link();
i would like to get:
$route_link = route_link('editorNew', array('id' => 1));
//$route_link containts "/editor/1"
I tried to use route()
, but i got http://localhost/app/public/editor-new/1
instead of /editor-new/1
and that’s not what i wanted.
For clarity need this functionality to generate links depending on machine, that the app is fired on (integration with Shopify).
2
Answers
You could use the following:
1
is the first value that will be on the route, at this moment{id}
.If you want to use the paramater (
id
) in your method, it will be the following:And in the view you could use:
Hope this works!
You can use
route
method to get the relative path by passingfalse
in the third parameter as: