Answer the question
In order to leave comments, you need to log in
Why doesn't $fillable work when calling create()?
protected $fillable = [
'rfid', 'name', 'phone', 'balance', 'email', 'identity_document', 'password', 'verified', 'avatar',
];
$values = [
'name' => $data['name'],
'email' => $data['email'],
'phone' => $data['phone'],
'password' => Hash::make($data['password']),
'identity_document' => 'storage/images/documents/'.$fileName,
];
return User::create($values);
SQLSTATE[HY000]: General error: 1364 Field 'identity_document' doesn't have a default value (SQL: insert into `users` (`name`, `email`, `phone`, `password`, `updated_at`, `created_at`) values (Yurii Kulaxyz, [email protected], +357939606674, $2y$10$/VONPcRE2.FQ1my1hM1LiOwtU.oWm4rotpY0JNHMU3DkW./1d5WnO, 2019-12-27 15:52:44, 2019-12-27 15:52:44))
Answer the question
In order to leave comments, you need to log in
Understood. The problem was that I am using "mutator method" setIdentityDocumentAttribute($value);
which was not correctly written.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question