Support the ongoing development of Laravel.io →
Authentication Database Eloquent

Hello

So, I want to get routes like these


myweb.com/account/company1/adm
myweb.com/account/company2/adm
myweb.com/account/company1/user/johnsmith
myweb.com/account/company1/user/juliaroberts


but, of course, they need to be dynamic in the segments company and name of user (myweb.com/account will be hardcoded named route)

I have a snippet of a controller which authorizes fine, but I dont know how to redirect it to a page that corresponds to the current logged user company and name. Since I could not, I just hardcoded a name at the end as johnsmit

return Redirect::intended('account/company/user/johnsmith


$authadm = Auth::attempt(array(                            
'email' => Input::get('email'),                            
'password' => Input::get('password'),                     
'active' => 1,
                            
'status' =>'super'                                                    
));



if($authadm){
                       
                        
  //Redirect to the intended page
                        
  return Redirect::intended('account/company/'user/johnsmith); 

What I tried:

I tried to insert in that redirect something like this: ,



Auth::user()->company, Auth::user()->username;


but it gave this error:

InvalidArgumentException

The HTTP status code "0" is not valid.

So, unable to solve that, I continued with what I had hardocoded as return Redirect::intended('account and I got to this route: ('account/adm/');

So, once I am at the adm route page I have this link



<p>{{ link_to_route('account.adm.users.index', 'See table users') }}</p>

and this takes me to a controller method named index which has this code:

                                            
$users = User::all();
return View::make('account.manageusers', compact('users'));

but this, of course, displays me all the rows of all members but again, I want that only the rows that would correspond to the currently logged in user are displayed.

I dont know if instead I should redirecto to a controller action, something like this:

return Redirect::action('HomeController@index');

and in that controller try to get the current user and from that row get the rest of the segments of the URL but I think I should be able to fix that in the controller where I already am at.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.