In v1.* of Livewire when using the Route::livewire()
syntax, I could use a route group and use the fluent ->layout()
directive to assign a layout to a group of Livewire components:
Route::layout('my.custom.layout')->middleware('auth')->group(function()
Route::livewire(...); // v1 syntax
});
With the v2 overhaul eliminating Route::livewire()
, we now have the ->extends()
and ->layout()
directives, but they go onto our component render
methods instead.
The thing is… I still want to apply the same layout to all of my Livewire components… and now cannot use the same Route Group approach. I have experimented with trying to chain various things to Route::group()
, but so far cannot get anything to work - I am stuck defining my layout and section on EVERY full-page Livewire component… which is a lot as I am trying to replace controllers in my app with this. It’s workable but doesn’t feel very DRY to me.
I checked docs and config files and a bit of source, and have come up empty.
Anyone else out there have ideas? Am I missing something here, or even in core Laravel, that might help me accomplish this?