php - i made a testing class in laravel and using factory in it to make a user but it is giving error that "fname" doesn't have a default value
public function test_case1()
{
$user = factory(User::class)->create([
'fname' => "Testing",
'lname' => 'bot',
'email' => "testing_bot@apimio.com",
'password' => bcrypt("testing_bot"),
]);
$this->assertTrue($user->is_subscribed());
}
this code is giving error
General error: 1364 Field 'fname' doesn't have a default value (SQL: insert into users
(updated_at
, created_at
) values (2022-01-31 08:44:43, 2022-01-31 08:44:43))
when i run test
NOTE:: This code is working fine on my teammate's pc but not on mine and i dont know why :(
Answer
Solution:
Check the User
model for something along the name of $fillable
this should be an array of values that are mass assignable for the purposes of factories.
Then you have to include the one's in your example.
Source