return view('posts.show') ->layoutData(['title' => 'Show Posts'])
Now from the layouts page, you can access the "title" variable but do note to check if the value exists using "isset()" directive like below.
@isset($title) <h1>{{ $title }}</h1> @endisset
If you prefer to provide a different layout page then you can use the "layouts()" method like below.
return view('posts.show') ->layout('layouts.base', ['title' => 'Show Posts'])
Leave a reply