I am having this error and none of the googled result i checked is similar to my problem.
I have an application with class Deal, User, and Matches
A deal has
If you have a constructor in your model, just make sure it has a call to a parent constructor as well:
public function __construct( array $attributes = array() ) {
// mandatory
parent::__construct($attributes);
//..
}
Otherwise, it will break some functionality like Model::create
.
If you would like to revert to previous behavior, update your
config/database.php
file and set 'strict' => false
for your connection.
Since it was a unique field in my case, I could not make it nullable.
For me, I had an empty constructor which was causing the issue don't know why. Please comment if anyone knows the reason.
public function __construct(){
}
Commenting/removing it resolved the issue.
I am using Laravel 8 and fixed this error thorugh this two steps:
move the word from $guarded
array to $fillable
array in User Mode
Config.database.php: 'strict' => false
in the array of 'mysql'
Another way around this error is to include
'strict' => false,
into config/database.php within mysql array
Remove the guarded
array and add the fillable
instead:
protected $fillable = ['user_id', 'deal_id'];