You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trying to serialize a model with using the include option will not trigger the associated model`s to_array() function
for example
class User extends ActiveRecord\Model {
static $belongs_to = array('owner');
function to_array(array $options = array()) {
$arr = parent::to_array($options);
$arr['custom_user_attribute'] = 'This value will be added';
return $arr;
}
}
class Owner extends ActiveRecord\Model {
function to_array(array $options = array()) {
$arr = parent::to_array($options);
$arr['custom_owner_attribute'] = 'This value will not be displayed';
return $arr;
}
}
$user = User::find(1);
$user->to_array(array(
'include' => array(
'owner'
)
));
i solved this by either manually using the associated models **to_array()** function or updating the **Serialization.php** files check_include() function:
trying to serialize a model with using the include option will not trigger the associated model`s to_array() function
for example
i solved this by either manually using the associated model
s **to_array()** function or updating the **Serialization.php** file
s check_include() function:The text was updated successfully, but these errors were encountered: