1.

How to do request validation in Laravel?

Answer»

Request validation in laravel can be done with the controller method or we can CREATE a request validation class that HOLDS the rules of validation and the error messages associated with it.

One example of it can be seen below:

/** * Store a NEW blog post. * * @PARAM \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */public function store(Request $request){ $validated = $request->validate([ 'title' => 'required|unique:posts|max:255', 'body' => 'required', ]); // The blog post is valid...}


Discussion

No Comment Found