Answer the question
In order to leave comments, you need to log in
How to output multiple Blade blocks with the same template?
There is a modal.blade.php with a modal window template from bootstrap 4.
<div id="@yield('modal_id')" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog @yield('modal_dialog_styles') modal-dialog-centered" role="document">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"></button>
<div class="modal-header">
<h3 class="modal-title text-center">@yield('modal_title')</h3>
</div>
<div class="modal-body">
<div class="row justify-content-center">
<div class="col-12 col-lg-10">
@section('modal_body')
@overwrite
</div>
</div>
</div>
<div class="modal-footer row justify-content-center">
@section('modal_footer')
@overwrite
</div>
</div>
</div>
</div>
@extends('modals.modal')
@section('modal_id', 'id-modal')
@section('modal_title', 'заголовок модального окна')
@section('modal_body')
Контент модального окна
@overwrite
@include('modals.modal1')
@include('modals.modal2')
Answer the question
In order to leave comments, you need to log in
Use components to accomplish this task.
/resources/views/modal.blade.php:
<div id="{{ $modal_id }}" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog {{ $modal_dialog_styles}} modal-dialog-centered" role="document">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"></button>
<div class="modal-header">
<h3 class="modal-title text-center">{{ $modal_title }}</h3>
</div>
<div class="modal-body">
<div class="row justify-content-center">
<div class="col-12 col-lg-10">
{{ $slot }}
</div>
</div>
</div>
<div class="modal-footer row justify-content-center">
{{ $modal_footer }}
</div>
</div>
</div>
</div>
@component('modal', ['modal_id' => '1', 'modal_title' => 'Модальное окно'])
Содержание окна
@endcomponent
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question