JezK
Edit File: GalleryResource.php
<?php namespace App\Http\Resources; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class GalleryResource extends JsonResource { /** * Transform the resource into an array. * * @return array<string, mixed> */ public function toArray(Request $request): array { return [ 'id' => $this->id, 'title' => $this->title, 'description' => $this->description, 'gallery_category' => $this->galleryCategory ? ['id' => $this->galleryCategory->id, 'name' => $this->galleryCategory->name, 'slug' => $this->galleryCategory->slug] : null, 'type' => $this->type, 'image_url' => $this->image_url, 'youtube_url' => $this->youtube_url, 'created_at' => $this->created_at, ]; } }