I am trying to use two different layouts for the front end and admin panel in my Laravel 11 application with Livewire. In livewire.php, the ‘layout’ option is set to ‘components.layouts.app’. I want to configure separate layouts for each section. How can I dynamically switch layouts based on the current route or user role so that the front end uses one layout and the admin panel uses another? Is there a way to achieve this within Livewire components or by extending the base Livewire configuration?
0
You can specify the layout using the #[Layout()] PHP attribute
#[Layout('my-layout')]
public function render() {
....
or chaining the view() helper with the layout() method:
public function render() {
return view('livewire.my.view')->layout('my-layout');
}
Here you can find the related documentation