Home > Net >  Laravel 8: create two different default app file
Laravel 8: create two different default app file

Time:11-29

In the application there is column type where the type are: Users and Admin.

I want to separate the app file of users to admin.

I already edited the file of

AuthenticatedSessionController

if($user_details->type != 0)
{
    return redirect()->intended(RouteServiceProvider::HOME);
}else{
    return redirect()->intended(RouteServiceProvider::SUPERADMINHOME);
}

I added SUPERADMINHOME in RouteServiceProvider

RouteServiceProvider

public const SUPERADMINHOME = '/app/super-admin/dashboard';

In web, I also added the route

My problem is, when the user logged in the superadmin it should load the super-admin-app not the app.blade.php

Reason why I want to separate the app file because whenever there will be change in app(for example) it should not effect the other one.

Question: Is it possible to separate the app file of users & admin?

CodePudding user response:

You can do it with route routing.

if($user_details->type != 0)
{
     return redirect()->route('user.home');//route name
}else{
     return redirect()->route('admin.home');//route name
}

You can send it to the view in the route you are redirecting.

CodePudding user response:

After how many hours of research, this is the solution that I'm looking at.

In SuperAdminDashboard, I added layouts to my super-admin-dashboard

SuperAdminDashboard

return view('livewire.super-admin-dashboard',[
        'company'                       =>$company
    ])
    ->layout('layouts.super-admin-app');
  • Related