laravel api validation response 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: php artisan make:request
php artisan make:request User\CreateUserRequest
Example 3: laravel check if api request
if (Request::wantsJson()) {
// return JSON-formatted response
} else {
// return HTML response
}