I have a model Foo that corresponds to a table with the following columns.
id
description
user_id
I\'m setting the attributes of the Foo model individual
Add the $fillable and the model will ignore everything not in it (instead of giving an error). Using the constructor function to fill all the columns is optional.
class Foo extends Model
{
protected $fillable = ['id', 'description', 'user_id'];
}
$f = new Foo(['id' => 1, 'description' => "hello monkey", 'user_id' => 55, 'bar' => 'wow']); // should work w/o error, but it ignores the 'bar'.