I would like $protected $foo to be assigned 'foo' in the static::creating event, but when I output the final object, the property is null. The event does not seem to fire:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Item extends Model {
protected $foo;
public static function boot() {
parent::boot();
static::creating(function (Item $item) {
echo "successfully fired"; //this does not get echoed
$item->foo = 'foo';
});
}
}
What am I doing wrong?