image = $data->image ?? null; $this->document = $data->document ?? null; $this->relation = isset($data->relation) ? new attachment_relation($data->relation) : null; $this->other = $data->other ?? null; } public function toArray(): array { return [ 'image' => $this->image, 'document' => $this->document, 'relation' => $this->relation ? $this->relation->toArray() : null, 'other' => $this->other, ]; } /** Setters */ public function setOther(mixed $string): self { $this->other = $string; return $this; } public function setImage(string $string): self { $this->image = $string; return $this; } public function setDocument(string $string): self { $this->document = $string; return $this; } public function setRelation(attachment_relation $relation): self { $this->relation = $relation; return $this; } }