July 2018
Intermediate to advanced
420 pages
8h 46m
English
Well, we have gone through a lot of theory, so now it is time to write some code. Let's implement the Validator on API controllers:
use Validator;
$validator = Validator::make($request->all(), [ 'make' => 'required', 'model' => 'required', 'year'=> 'required', 'mods'=> 'required', 'builder_id' => 'required']);if ($validator->fails()) { return response()->json($validator->errors(), 422);}
Note that, in the previous code, we are using the response JSON format and set the errors and status code as parameters ...
Read now
Unlock full access