Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mehmetanbaki's avatar

Roles Redirect

Hey Laravelers

I make four roles login to my system

  1. admin
  2. accountant 3)customer 4)staff

I want the last two roles connecting to the same dashboard which is the company dashboard from there role according to there company not to other companies how can I do that ??

0 likes
6 replies
hemmy6894's avatar

Do it manually!

if(Auth::attempt($request->only('email','password')){
    if(Auth::check()){
        if(Auth::user()->role == 1){
            return redirect()->route('admin');
        }

        if(Auth::user()->role == 2){
            return redirect()->route('accountant');
        }
    }
}
mehmetanbaki's avatar

that's not my point

I want only the customer role and staff role access to their company dashboard only not the main dashboard for the admin and according to their company only their company dashboard not other companies dashboard

that's what I mean exactly can't make them access to other companies dashboard

mehmetanbaki's avatar

no that's not not what I mean look when I create a user with role customer or staff they both of them work for only one company so I want them access to the information for only and only that company not the others company ok ??? is it clear now or not ??

Agoi's avatar

In that case, they will still be redirected to the same dashboard. Just that on that dashboard, you will use the company_id (as an example) to get the actual content for that company hence the user will see only its company content.

mehmetanbaki's avatar

exactly that what I'm saying I want get the company content with company id and customer id or staff id

Please or to participate in this conversation.