change error message laravel code example
Example 1: displaying errors in laravel
@if(count($errors) > 0)
<div class="p-1">
@foreach($errors->all() as $error)
<div class="alert alert-warning alert-danger fade show" role="alert">{{$error}} <button type="button" class="close"
data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button></div>
@endforeach
</div>
@endif
Example 2: how to add an custom error to validater error in laravel
if (request('event') == null) {
$validator->errors()->add('event', 'Please select an event');
}
Example 3: laravel unique validation
unique:table,column,except,idColumn
############## Example : ################
############### For Updating
'email' => 'unique:users,email_address,' . $userId,
############### For Creating
'email' => 'unique:users,email_address',
Example 4: validate field for existing client laravel
unique:users,username,id,1