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 ...

1

1 Answer 1

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.