Hi all, I am creating an app that when the user logs in, the user id is in the url like "domain.com/1234567/somepage". In my routes I am able to grab the id like so
Route::group(array('prefix' => '{account_id}','before' => 'auth'), function()
{
Route::resource('somepage', 'SomepageController');
});
But I don't know how to fix or modify something like {{ URL::to('somepage/create') }} so that it creates the URL like "domain.com/1234567/somepage/create" instead of "domain.com/somepage/create"
Can someone give me some ideas?
John
Since you are using the "before" filter for that set of routes you could use
URL::to(Auth::user()->id.'/somepage/create');
You could also use named routes and do
URL::route("name_of_your_route")->with(array('user_id' => Auth::user()->id));
Which ever you prefer my point is that you could get the current user's id through
Auth::user()->attribute;
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community