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
  • did as you wrote ..... the result is the same ..... 0 1 2 3 4 5 6 7 8 9 - Alexander
  • Show me how I did :) - Orange_shadow
  • added code fix to the question .... - Alexander
  • one
    Remove everything but the div does not need @extends('index') , @section('block') , just leave only html - Orange_shadow

1 answer 1

I fixed the files as instructed by Orange_shadow and it all worked! Here is a ready-made version of the index.blade.php files:

 @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:

  <div class="container"> <p>block</p> </div>