4

I am trying something really simple and can not get it to work. I have 2 pages. admin.blade.php and left.blade.php I am trying to use admin page as the master page. and include date from left.blade.php

The admin pages print only "test" as the result and includes nothing from left.admin.php. I can`t see what is wrong. Thanks in advance

File structure is

-- resources
   --views
     *admin.blade.php
     *left.blade.php

left.blade.php

@extends('admin')

@section('content')
   baran
@stop

admin.blade.php

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
    <title> @yield('title')</title>
</head>
<body>
    <?php
    // put your code here
    ?>

    @yield('content')

    test
<div id='footer'>
    @yield('footer')
</div>
</body>
</html>

route command in web.php is

Route::get('/admin', function () {
    return view('admin');
});
rematnarab
  • 1,277
  • 4
  • 22
  • 42

2 Answers2

3

If you want to include date from left.blade.php you should use @include() directive in admin.blade.php:

@include('left')

If your main content is in left.blade.php and you're using admin.blade.php as layout only then change you route:

Route::get('/admin', function () {
    return view('left');
});
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
1

You want to call the view for the inner page, not the master page, since the inner page extends the master page:

return view('left');
aynber
  • 22,380
  • 8
  • 50
  • 63