uuid = Uuid::v4()->toRfc4122(); $this->createdAt = time(); $this->updatedAt = time(); } public static function forDoctor(Doctor $doctor): self { $a = new self(); $a->type = self::TYPE_PERSONAL; $a->doctor = $doctor; return $a; } public static function forClinic(int $clinicId): self { $a = new self(); $a->type = self::TYPE_CLINIC; $a->clinicId = $clinicId; return $a; } public function getId(): ?int { return $this->id; } public function getUuid(): string { return $this->uuid; } public function getDoctor(): ?Doctor { return $this->doctor; } public function getClinicId(): ?int { return $this->clinicId; } public function getType(): string { return $this->type; } public function getName(): ?string { return $this->name; } public function getAddress(): ?string { return $this->address; } public function getTelephone(): ?string { return $this->telephone; } public function getLatitude(): ?float { return $this->latitude; } public function getLongitude(): ?float { return $this->longitude; } public function getCity(): ?City { return $this->city; } public function getProvince(): ?Province { return $this->province; } public function setName(?string $v): self { $this->name = $v; return $this; } public function setAddress(?string $v): self { $this->address = $v; $this->touch(); return $this; } public function setTelephone(?string $v): self { $this->telephone = $v; $this->touch(); return $this; } public function setLatitude(?float $v): self { $this->latitude = $v; $this->touch(); return $this; } public function setLongitude(?float $v): self { $this->longitude = $v; $this->touch(); return $this; } public function setCity(?City $v): self { $this->city = $v; $this->touch(); return $this; } public function setProvince(?Province $v): self { $this->province = $v; $this->touch(); return $this; } private function touch(): void { $this->updatedAt = time(); } public function toArray(?string $clinicName = null): array { return [ 'id' => (string) $this->id, 'uuid' => $this->uuid, 'type' => $this->type, 'clinic_id' => $this->clinicId, 'clinic_name' => $clinicName, 'name' => $this->name, 'map' => [ 'latitude' => $this->latitude !== null ? (string) $this->latitude : null, 'longitude' => $this->longitude !== null ? (string) $this->longitude : null, ], 'address' => $this->address, 'telephone' => $this->telephone, 'city' => $this->city !== null ? [ 'id' => (string) $this->city->getId(), 'name' => $this->city->getName(), ] : null, 'province' => $this->province !== null ? [ 'id' => (string) $this->province->getId(), 'name' => $this->province->getName(), ] : null, ]; } }