uuid = Uuid::v4()->toRfc4122(); $this->orderId = 'ORD-' . strtoupper(substr(str_replace('-', '', Uuid::v4()->toRfc4122()), 0, 16)); $this->user = $user; $this->amountRials = $amountRials; $this->gateway = $gateway; $this->type = $type; $this->frontendAddress = $frontendAddress ?: null; $this->createdAt = time(); $this->updatedAt = time(); } public function getId(): ?int { return $this->id; } public function getUuid(): string { return $this->uuid; } public function getOrderId(): string { return $this->orderId; } public function getUser(): User { return $this->user; } public function getAppointment(): ?Appointment { return $this->appointment; } public function getAmountRials(): int { return $this->amountRials; } public function getStatus(): string { return $this->status; } public function getGateway(): string { return $this->gateway; } public function getType(): string { return $this->type; } public function getGatewayToken(): ?string { return $this->gatewayToken; } public function getReferenceId(): ?string { return $this->referenceId; } public function getFrontendAddress(): ?string { return $this->frontendAddress; } public function getCallbackIp(): ?string { return $this->callbackIp; } public function getMetadata(): ?array { return $this->metadata; } public function setAppointment(?Appointment $a): self { $this->appointment = $a; return $this; } public function setMetadata(?array $metadata): self { $this->metadata = $metadata; $this->touch(); return $this; } public function setGatewayToken(?string $t): self { $this->gatewayToken = $t; $this->touch(); return $this; } public function setReferenceId(?string $r): self { $this->referenceId = $r; $this->touch(); return $this; } public function setStatus(string $s): self { $this->status = $s; $this->touch(); return $this; } public function setCallbackIp(?string $ip): self { $this->callbackIp = $ip; $this->touch(); return $this; } public function setFrontendAddress(?string $a): self { $this->frontendAddress = $a ?: null; $this->touch(); return $this; } private function touch(): void { $this->updatedAt = time(); } public function toArray(): array { return [ 'uuid' => $this->uuid, 'order_id' => $this->orderId, 'amount_rials' => $this->amountRials, 'status' => $this->status, 'gateway' => $this->gateway, 'type' => $this->type, 'reference_id' => $this->referenceId, 'appointment_uuid' => $this->appointment?->getUuid(), 'created_at' => $this->createdAt, ]; } }