I'm new to Laravel & right now building one application on L-4 but got stuck at one place. Can't able to understand how to generate url relative to base url. In laravel-3 i know this can be done by
$url = URL::to('user/profile');
But, in L-4 how we can do this.. ?
To generate a relative URL, you can use
URL::route
orURL::action
as they allow to pass a$absolute
parameter which defaults totrue
. So to get a relative URL when using named routes for example, you can use the following:This will generate a URL like
/foobar
.First you need to create a Named Route like
Say yo want to go to
http://baseurl/user
and runs the method 'showuser' define in controller 'allusers'then your Route shold look like this:-
Now your URL to /user would be
I hope this helps you. Pls refer http://laravel.com/docs/routing#named-routes