I am using Laravel with Vue making http request with the axios. It is giving 500 error. My request code is
axios.post('user', {
first_name: this.user.first_name,
last_name: this.user.last_name,
email: this.user.email,
phone_number: this.user.phone_number,
is_active: this.user.is_active,
entity: this.user.entity,
role_id: this.user.role_id
})
Lavael Route is
Route::resource('user', 'UserController');
And Controller is
public function store(Request $request)
{
$this->validate($request, [
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required',
'is_active' => 'required'
]);
$user = User::create([
'first_name' => request('first_name'),
'last_name' => request('last_name'),
'email' => request('email'),
'is_active' => request('is_active'),
'phone_number' => request('phone_number'),
'role_id' => request('role_id')
]);
return response()->json([
'user' => $user,
'message' => 'Success'
], 200);
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BJxqNY
via IFTTT
Aucun commentaire:
Enregistrer un commentaire