2

how send data between child and master blade ?

*master.blade.php*

@if($sidebar == 'true')
<div>...</div>
@endif

*index.blade.php*
@extends('master')
@section('sidebar','true')

please help me. do not use Route and controller and ...

  • https://stackoverflow.com/questions/16118104/how-do-i-pass-a-variable-to-the-layout-using-laravel-blade-templating I think it will help you – Saromase Jun 25 '21 at 07:48

1 Answers1

1

To pass a variable from the child to the parent, the parent must first specify that it expects a variable. This is done using the yield keyword

master.blade.php

@if(@yield('hasSidebar') == '1')
<div>...</div>
@endif

index.blade.php

<?php

  @extends('master')

  @section('hasSidebar', '1')
Dharman
  • 30,962
  • 25
  • 85
  • 135
Adonai Nangui
  • 451
  • 4
  • 8