In such scenario, you can try doing the reverse. For example: id
, created_at
and updated_at
field as $guarded. Like:
protected $guarded = ['id', 'created_at', 'updated_at'];
Except these rest will be considered as fillable
i.e. mass assignable.
You can find details in Official Laravel Doc
Guarding Attributes
While $fillable serves as a "white list" of attributes that should be
mass assignable, you may also choose to use $guarded. The $guarded
property should contain an array of attributes that you do not want to
be mass assignable. All other attributes not in the array will be mass
assignable. So, $guarded functions like a "black list". Of course,
you should use either $fillable or $guarded - not both.