Inertia Does not Returning any validation errors
Here is my controller code
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
Request::validate([
'firstName' => ['required', 'string', 'max:100'],
'lastName' => ['required', 'string', 'max:100'],
'shopName' => ['required', 'string', 'max:100'],
'email' => ['required', 'email', Rule::unique('vendors', 'email')],
'mobile' => ['required', 'string'],
'password' => ['required', 'min:6', 'max:12', 'confirmed']
]);
Vendor::create($request->validated());
return Redirect::route('vendors.create')->with('success', 'Vendor created.');
}
Here is my vue component code
export default {
name: "Create Vendor",
props: {
auth: Object,
errors: Object,
},
data() {
return {
form: this.$inertia.form({
firstName: null,
lastName: null,
shopName: null,
email: null,
mobile: null,
password: null,
password_confirmation: null,
}),
};
},
methods: {
store() {
return this.form.post(this.route("vendors.store"));
},
},
};
But after submit the error object is always empty
Note: I have also set the HandleInertiaRequest middleware.
source https://stackoverflow.com/questions/67826997/laravel-inertia-not-returning-validation-errors
No comments:
Post a Comment