id = $data['id'] ?? null; $this->title = $data['title'] ?? ''; $this->content_type = $data['content_type'] ?? 'image'; $this->content_value = $data['content_value'] ?? ''; $this->link_url = $data['link_url'] ?? ''; $this->position = $data['position'] ?? 'top'; $this->display_type = $data['display_type'] ?? 'inline'; $this->start_time = $data['start_time'] ?? null; $this->end_time = $data['end_time'] ?? null; $this->user_target = $data['user_target'] ?? 'all'; $this->device_target = $data['device_target'] ?? 'all'; $this->priority = isset($data['priority']) ? (int) $data['priority'] : 10; $this->status = isset($data['status']) ? (int) $data['status'] : 1; $this->impressions = isset($data['impressions']) ? (int) $data['impressions'] : 0; $this->clicks = isset($data['clicks']) ? (int) $data['clicks'] : 0; $this->created_at = $data['created_at'] ?? null; } public function toArray() { return [ 'id' => $this->id, 'title' => $this->title, 'content_type' => $this->content_type, 'content_value' => $this->content_value, 'link_url' => $this->link_url, 'position' => $this->position, 'display_type' => $this->display_type, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'user_target' => $this->user_target, 'device_target' => $this->device_target, 'priority' => $this->priority, 'status' => $this->status, 'impressions' => $this->impressions, 'clicks' => $this->clicks, 'created_at' => $this->created_at, ]; } }