Passing a fallback view in your @yield directive

Submitted by laraning - 3 years ago

If you have a @yield directive, you know that you can pass a default content in the 2nd argument. What if you want to pass the content of a view?

// You can have this:


// Or with a default content:

@yield('repository', 'nothing exists')

// And with a fallback view content:

  $fallbackView = view('')

@yield('repository', $fallbackView)
// Voilá :)