@martinbean The issue is that I’m currently passing a whole set of variables to the view like this:
public function index()
{
return view('main')->with([
'title' => 'Some title',
'description' => 'Some description',
]);
}
Then, I forward them to the layout:
<x-layout :title="$title" :description="$description">
...
</x-layout>
Only at that point are they rendered:
<title>{{ $title }}</title>
@isset($description)
<meta name="description" content="{{ $description }}">
@endisset
The problem arises when I want to introduce another "global" layout variable—for example, a custom meta tag or a flag to toggle the sidebar on a specific page. In this case, I would have to update all my views just to pass that new variable through to the layout.
In Yii, this was handled differently: I would simply add a new property to the base controller class, assign it a sensible default, and it would immediately be available in the layout—no need to pass it explicitly through every individual view.