'array', 'queued_at' => 'datetime', 'started_at' => 'datetime', 'finished_at' => 'datetime', 'expires_at' => 'datetime', 'deleted_at' => 'datetime', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function artwork(): BelongsTo { return $this->belongsTo(Artwork::class); } public function isPending(): bool { return $this->status === self::STATUS_PENDING; } public function isQueued(): bool { return $this->status === self::STATUS_QUEUED; } public function isProcessing(): bool { return $this->status === self::STATUS_PROCESSING; } public function isCompleted(): bool { return $this->status === self::STATUS_COMPLETED; } public function isFailed(): bool { return $this->status === self::STATUS_FAILED; } public function canBeDeletedBy(User $user): bool { if ($user->isAdmin() || $user->isModerator()) { return true; } return (int) $this->user_id === (int) $user->id && in_array($this->status, [self::STATUS_PENDING, self::STATUS_FAILED, self::STATUS_COMPLETED, self::STATUS_CANCELLED, self::STATUS_EXPIRED], true); } public function sourceUrl(): ?string { return $this->resolveDiskUrl($this->source_disk, $this->source_path); } public function outputUrl(): ?string { return $this->resolveDiskUrl($this->output_disk, $this->output_path); } public function previewUrl(): ?string { return $this->resolveDiskUrl($this->preview_disk, $this->preview_path); } private function resolveDiskUrl(?string $disk, ?string $path): ?string { $trimmedPath = ltrim(trim((string) $path), '/'); if ($trimmedPath === '') { return null; } $configuredDisk = trim((string) config('enhance.disk', 'public')); $targetDisk = trim((string) $disk) ?: $configuredDisk ?: 'public'; // For non-local disks (e.g. S3-backed), construct the CDN URL directly. // For local disks ('public', 'local') fall through to Storage::disk()->url() // so that the correct APP_URL-based path is returned in non-CDN environments. $base = rtrim((string) config('cdn.files_url', ''), '/'); if ($base !== '' && $targetDisk === $configuredDisk && ! in_array($targetDisk, ['public', 'local'], true)) { return $base . '/' . $trimmedPath; } $url = Storage::disk($targetDisk)->url($trimmedPath); if (str_starts_with($url, 'http://') || str_starts_with($url, 'https://')) { return $url; } return url($url); } }