Search code examples
laravellaravel-livewirelaravel-jetstream

How to change default layout in Laravel8, livewire2 app?


I made in Laravel8, livewire2 3 layouts : resources/views/layouts/admin.blade.php, resources/views/layouts/frontpage.blade.php, resources/views/layouts/personal.blade.php and removed original layouts.app.blade.php.

But opening dashboard page I got error :

View [layouts.app] not found. (View: /resources/views/dashboard.blade.php)

Which has default content :

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Dashboard') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
                <x-jet-welcome />
            </div>
        </div>
    </div>
</x-app-layout>
  1. Can I specify layout in file above ?

  2. Here https://laravel-livewire.com/docs/2.x/rendering-components#page-components I read :

If you want to specify a default layout other than the layouts.app, you can override the livewire.layout config option.

'layout' => 'app.other_default_layout'

But I did not find any “livewire.layout” file in my project. How can I create it?

Thanks!


Solution

  • you should publish the livewire config file using the command

    php artisan livewire:publish --config
    

    next, you can find it in config/livewire.php