Many times we need some sections of HTML which need to be incorporated in many views and just to reduce redundancy we create separate views for it.
An example to accomplish that is stated below:-
Including other views in other view syntax :-
@include('partials.alerts.errors')
@include('partials.alerts.success')
Create a view as errors inside /resources/views/partials/alerts/errors.blade.php
@if($errors->any())
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
@foreach($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
</ul>
</div>
@endif
Create a view as success inside /resources/views/partials/alerts/success.blade.php
@if(Session::has('success'))
<div id="flashSucessMessage" class="alert alert-success">{!! Session::get('success') !!}</div>
@endif
0 Comment(s)