I have done searches and cannot find anything that solves this in Laravel 5.2.
Is it possible to generate relative URLs in Laravel 5.2?
Meaning, instead of http://example.com/mypage
I get simply /mypage
?
If you are trying to generate them, rather than retrieve the current one, you can pass a 3rd parameter to the route
function.
echo route('about', [], false);
If you pass true
(the default) as the 3rd parameter it will give you
http://example.com/about
If you pass false
as the 3rd parameter it will give you
/about
Yes, you should use $request->path()
, it will return the URI
.
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