Open
Description
When creating an AbstractModel
via the several builder methods:
$model = new Model(['attribute' => 'value']);
$model = $parent->create_model = ['attribute' => 'value'];
$model = $parent->build_model = ['attribute' => 'value'];
The model expects the attribute to match the column type. Only issue with that is if we have a magic setter for a particular attribute:
public function set_attribute(\DateTime $attribute) {
$time_stamp = $attribute->getTimestamp();
// Attribute in DB column expects an int type, not a DateTime
$this->assign_attribute('attribute', $time_stamp);
}
The magic setter will be called during the magic creation but we get an error no matter what is passed in as the value. This is because if the value passed in is an int
, the magic setter expects a DateTime
. If the value passed in is a DateTime
the mass assignment during the magic creation expects the type to be in parity with the table column (an int
).