master.blade.php (part of body code):
<body> <div id="content"> @yield('content') </div> </body> index.blade.php:
@extends('master') @section('content') @for ($i = 0; $i < 10; $i++) @yield('block') {{ $i }} @endfor @endsection block.blade.php:
@extends('index') @section('block') <div class="container"> <div class="row"> <div class="col-md-3" style="background: red; height: 100px"> <p>block</p> </div> <div class="col-md-6" style="background: blue; height: 100px"> <p>block</p> </div> </div> </div> @endsection In this code, a template for a web page is written in the master.blade.php file. In the index.blade.php file in the for statement, the block is called, which is described in the block.blade.php file. MUST BE: display of 10 blocks described in the block.blade.php file
RESULT: numbers 0 1 2 3 4 5 6 7 8 9
What's wrong?
Corrected ....
index.blade.php:
@extends('master') @section('content') @for ($i = 0; $i < 10; $i++) @include('block') {{ $i }} @endfor @endsection master.blade.php:
<div id="content"> @yield('content') </div> block.blade.php:
@extends('index') @section('block') <div class="container"> <p>block</p> </div> @endsection Receive such a variation a blank white screen is obtained ....
@include('block')- use and remove everything except<div class="container">..</div>and the variables will all pick up - Orange_shadow@extends('index'),@section('block'), just leave only html - Orange_shadow