Laravel AutoHydrate Ardent Model, but sometimes manually assign?

167 views Asked by At

So I have my Model setup like this:

protected $fillable = array('dragon_id', 'name', 'gender');

public $autoHydrateEntityFromInput = true;    // hydrates on new entries' validation
public $forceEntityHydrationFromInput = true; // hydrates whenever validation is called

However in ONE instance, I need to manually assign some of the attributes.. is there a way to do this? Because when I manually assign with auto hydrate set to true, it overwrites what I manually set.

Thanks for any help/suggestions!

1

There are 1 answers

0
Pete Thorne On

I had the same problem, if you set public $forceEntityHydrationFromInput = false; (or comment out completely) then you can call:

$newModel = MyModelClass::create(arrayOfAttributes);

And it will not auto hydrate.