@lew
To create a dynamic @yield
in Laravel, you can pass a variable to the yield
directive in your blade template. Here's an example of how you can achieve this:
1 2 3 4 |
$data = [ 'content' => 'This is some dynamic content' ]; return view('your-view')->with($data); |
1
|
@yield('content', 'Default content') |
1 2 3 |
@section('content') {{ $content }} @endsection |
This way, the variable content
will be dynamically passed to the yield
directive in your blade template and displayed in the child view. If the variable is not passed, the default content specified in the @yield
directive will be displayed instead.