*/ public function toArray(Request $request): array { $locale = $request->query(config('locales.query_parameter')) ?? app()->getLocale(); return [ 'id' => $this->id, 'locale' => $locale, ...TranslatablePayload::resolve($this->resource, $this->translatable, $locale), 'icon' => $this->icon, 'is_featured' => (bool) $this->is_featured, 'is_published' => (bool) $this->is_published, 'published_at' => $this->published_at?->toIso8601String(), 'unpublish_at' => $this->unpublish_at?->toIso8601String(), 'position' => $this->position, 'technology_ids' => $this->whenLoaded('technologies', fn () => $this->technologies->pluck('id')->values()), 'project_ids' => $this->whenLoaded('projects', fn () => $this->projects->pluck('id')->values()), 'created_at' => $this->created_at?->toIso8601String(), 'updated_at' => $this->updated_at?->toIso8601String(), 'deleted_at' => $this->deleted_at?->toIso8601String(), 'translations' => $this->when( in_array('translations', explode(',', (string) $request->query('with')), true), fn () => TranslatablePayload::all($this->resource, $this->translatable), ), ]; } }