protected function objectToRawArray($data, bool
$onlyChanged = true, bool
$recursive = false
): ?array
{ $properties = parent::
objectToRawArray($data,
$onlyChanged);
$primaryKey = null;
if ($data instanceof Entity
) { $cast =
$data->
cast();
// Disable Entity casting, because raw primary key data is needed for database.
$data->
cast(false
);
$primaryKey =
$data->
{$this->primaryKey
};