*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'legacy' => [ 'portal' => $this->legacy_portal, 'id' => $this->legacy_id, ], 'portal' => $this->portal?->value, 'is_active' => $this->is_active, 'translations' => $this->whenLoaded('translations', fn () => $this->translations ->mapWithKeys(fn ($translation) => [ $translation->locale => [ 'name' => $translation->name, 'slug' => $translation->slug, 'description' => $translation->description, ], ]) ->all()), ]; } }