So I am working on a Laravel 8 app, with Inertia and Vue.
The idea is that most of the pages are Laravel + Blade (good for SEO, fast loading etc...), but for selected pages that need a lot of user interactions, I insert a Vue component in the Blade Template where the interactions need to happen.
With Inertia, this is done by calling the Vue component with return Inertia::render('vueComponent')
in the Controller that is called by the Laravel Route. Data can be passed to the Vue instance, and even to the Blade template, so this is good (see below).
namespace App\Http\Controllers;
use Inertia\Inertia;
class RangePageController extends Controller
{
public function show(string $lang='fr')
{
// Strip the trailing slash from $lang
$lang = Str::before($lang, '/');
return Inertia::render('ProductsGallery', ['bar' => "Hello World"])->withViewData(['lang' => $lang]);
}
}
And by default, the file "/resources/views/app.blade.php" is rendered with the Vue component replacing the @inertia directive (plus some Vue Data). Neat.
By default, the Blade layout file "app.blade.php" is used. The doc specifies that the default can be changed: Inertia\Inertia::setRootView('name');
.
The Question: rather than changing the default, is there a way to choose different Blade layout files when calling different pages from the Controller (and inject the Vue component as above)? For instance I would like to use one Blade layout for my e-commerce basket, and a different one for my admin pages. Like choosing "app1.blade.php" for a page, and "app2.blade.php" for another.
Many thanks! E.