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 individually (no mass assignment)
$foo = new Foo;
$foo->id = 1;
$foo->description = "hello kitty";
$foo->user_id = 55;
//...
$foo is sent to another class for additional processing, but because that class needs a bit more information, I would like to simply add it to the $foo model.
//...
$foo->bar = $additional_information;
Event::fire(DoStuffWithFoo($foo));
$foo->save(); //error
the problem is when I $foo->save()
, it complains that bar
isn't a column.
I know I can unset($foo->bar);
before saving, but...
Is it possible to tell Eloquent to simply ignore any non relevant attributes?
$foo = new Foo($array);