I've got a problem with error messages during validation in Laravel. I've got my custom Request:
class CreateCv extends Request
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'required',
'surname' => 'required',
];
}
public function messages()
{
return [
'name.required' => 'Fill the name!',
'surname.required' => 'Fill the surname!',
];
}
}
and then I've got a controller with create method:
class CvController extends Controller
{
public function create(Requests\CreateCv $request) {
return response()->json(['ok' => true], 200);
}
}
If everything is filled up, then it returns json response "ok" : true
correctly. But when something is missing, then it returns empty msg: "msg": ""
. What causes this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire