Extending layout

Asked

Viewed 166 times

0

I have 2 files:

app.blade.php

<html>
<head>
    <title>App Name</title>
</head>
<body>
    <div class="container">
        @yield('content')
    </div>
</body>

php client.blade.

@extends('layouts.app')

@section('content')
   <form></form>
   <table></table>
   <div></div>
@endsection

I wonder if there’s like in the file php client.blade. extend another file?

Example of what I would like to do:

php client.blade.

@extends('layouts.app')

@section('content')
   @section('formulario') // Aqui uso section ou yield
   <table></table>
   <div></div>
@endsection

formulario.blade.php

@extends('cliente')

@section('formulario')
    <form></form>
@endsection

1 answer

0


replace in php client.blade.

@section('formulario')

for

 @yield('formulario')

form.Lade can keep as it is and then the content of the Section('form') of it enters the Yield('form') of the extended page

examples I used in my tests (My Laravel is 5.8) :

php.blade.:

@extends('layouts.master')
@section('user','Willian')

<!-- inicio do conteúdo -->
@section('content')

<textarea rows="5" class="form-control" placeholder="">@yield('descricao')</textarea>

@endsection

parssdesc.blade.php:

@extends('analises.analises')

@section('descricao')
    Teste
@endsection

route:

Route::get('/analises' , 'AnalisesController@index')

index method in Analyscontroller:

public function index(){
   return view('analises.analisesdesc');
}

result was the description field (textarea) with the word test

  • I tried that and I didn’t succeed. But I can do it?

  • gives... I just tested, but your route has to point to formuario.

  • Could you show me an example of the route?

  • edited the answer ai man. qlq thing of a touch

  • 1

    Thanks friend, clarified my doubt

  • There is no partner

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.