'message:json_string', 'Priority' => 'priority:json_string', 'Platform' => 'platform:json_string', 'Created' => 'created:datetime_epoch', 'SentDate' => 'sent_date:datetime_epoch', 'IsSent' => 'is_sent:json_boolean', 'Approved' => 'approved:json_boolean', 'OwnerId' => 'owner_id:json_int', 'ApprovedById' => 'approved_by_id:json_int', ]; /** * @param null $expand * @param array $fields * @param array $relations * @param array $params * @return array */ public function serialize($expand = null, array $fields = [], array $relations = [], array $params = []) { $notification = $this->object; if(! $notification instanceof PushNotificationMessage) return []; $values = parent::serialize($expand, $fields, $relations, $params); if (!empty($expand)) { $exp_expand = explode(',', $expand); foreach ($exp_expand as $relation) { switch (trim($relation)) { case 'owner': { if(!$notification->hasOwner()) continue; unset($values['owner_id']); $values['owner'] = SerializerRegistry::getInstance()->getSerializer($notification->getOwner())->serialize(); } break; case 'approved_by': { if(!$notification->hasApprovedBy()) continue; unset($values['approved_by_id']); $values['approved_by'] = SerializerRegistry::getInstance()->getSerializer($notification->getApprovedBy())->serialize(); } break; } } } return $values; } }