visit
@if(!empty($errors->first()))
<div class="row col-lg-12">
<div class="alert alert-danger">
<span>{{ $errors->first() }}</span>
</div>
</div>
@endif
Whenever I redirect the user back with an error I know the page will be capable of showing the message properly at the top because of the base template.
However, if you do this and then setup a Form Validation, you’ll see only the first error message on top of the page. We could go through all messages in the errors variable, but it would still be showing form errors on top of the page instead of under each field. To prevent that, we can leverage Message Bags from Laravel Form Requests.
use Illuminate\Foundation\Http\FormRequest;
class BaseFormRequest extends FormRequest {
protected $errorBag = 'form';
}
@if($errors->form->first($field))
{!! $errors->form->first($field, '<p><span class="text-warning">:message</span></p>') !!}
@endif
<div class="form-group">
<label>{{ __('What is the subject of this ticket?') }}</label>
<input type="text" name="title" class="form-control">
@include('layouts.components.alert.field', ['field' => 'title'])
</div>