*/ public function toArray(Request $request): array { $variants = is_array($this->variants) ? $this->variants : []; $variantUrls = []; foreach ($variants as $key => $relativePath) { if (is_string($relativePath) && filled($relativePath)) { $variantUrls[$key] = asset('storage/'.ltrim($relativePath, '/')); } } return [ 'id' => $this->id, 'press_release_id' => $this->press_release_id, 'url' => $this->url(), 'urls' => array_merge(['original' => $this->url()], $variantUrls), 'variants' => $variants, 'disk' => $this->disk, 'path' => $this->path, 'title' => $this->title, 'description' => $this->description, 'copyright' => $this->copyright, 'is_preview' => $this->is_preview, 'sort_order' => $this->sort_order, 'width' => $this->width, 'height' => $this->height, 'mime' => $this->mime, 'created_at' => $this->created_at?->toIso8601String(), 'updated_at' => $this->updated_at?->toIso8601String(), ]; } }