2 min read

Fail Validation

Laravel’s validation system takes care of all the dirty work for you, including redirecting the user back to the previous page with the correct status code and storing your errors on the session for easier display. This allows you to push validation error messages anywhere in the application.

           use Illuminate\Validation\ValidationException;
 
 throw ValidationException::withMessages([
     'field_name' => ['Custom message here'],
 ]);