Yes, it is possible to have two separate layouts in InertiaJS. You can achieve this by creating two separate root views for your end-user and admin sections.
First, create two separate root views in your resources/views directory. For example, you can create a file called "app.blade.php" for your end-user section and another file called "admin.blade.php" for your admin section.
In your controller, you can specify which root view to use for each section. For example:
public function index()
{
return Inertia::render('Index', [
'layout' => 'app', // use app.blade.php for end-user section
]);
}
public function adminIndex()
{
return Inertia::render('Admin/Index', [
'layout' => 'admin', // use admin.blade.php for admin section
]);
}
Then, in your root view files, you can include the appropriate CSS and JS files for each section. For example, in app.blade.php, you can include the Bootstrap 5 CSS and JS files, and in admin.blade.php, you can include the CoreUI CSS and JS files.
<!-- app.blade.php -->
<!DOCTYPE html>
<html>
<head>
<title>My App</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
</head>
<body>
@inertia
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<!-- admin.blade.php -->
<!DOCTYPE html>
<html>
<head>
<title>Admin</title>
<link rel="stylesheet" href="https://unpkg.com/@coreui/[email protected]/dist/css/coreui.min.css">
</head>
<body>
@inertia
<script src="https://unpkg.com/@coreui/[email protected]/dist/js/coreui.bundle.min.js"></script>
</body>
</html>
That's it! Now you have two separate layouts for your end-user and admin sections in InertiaJS.