I have a simple controller, Laravel 5.5, with some basic validation but when I enter invalid data, I submit the form and get a "ValidationException: The given data was invalid".
The framework is supposed to redirect me to the form with error messages, but I end up on the big red exception page.
Why would this be?
/**
* Store blog comment
*/
public function store(Request $request)
{
try {
$blogPost = BlogPost::where('id', '=', $request->blog_post_id)->get()->first();
if (!$blogPost) {
abort(404);
}
$validatedData = $this->validate($request, [
'blog_post_id' => 'required|numeric',
'blog_comment' => 'required|min:3',
'blog_comment_name' => 'required|min:3',
'blog_comment_company' => 'nullable'
]);
Here is the controller that is sending me back to the exception page.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire