disaplyin custom errors laravel code example
Example 1: if any error in blade laravel
@if ($errors->any())
@foreach ($errors->all() as $error)
<div>{{$error}}</div>
@endforeach
@endif
Example 2: $errors show this error in laravel
<input type="text" name="firstname">
@if($errors->has('firstname'))
<div class="error">{{ $errors->first('firstname') }}</div>
@endif
Example 3: how to add an custom error to validater error in laravel
if (request('event') == null) {
$validator->errors()->add('event', 'Please select an event');
}