*/ public function toArray(Request $request): array { $locale = $request->query(config('locales.query_parameter')) ?? app()->getLocale(); return [ 'id' => $this->id, 'locale' => $locale, 'name' => $this->name, 'slug' => $this->slug, ...TranslatablePayload::resolve($this->resource, $this->translatable, $locale), 'category' => $this->category->value, 'radar_ring' => $this->radar_ring?->value, 'color' => $this->color, // The stored path, which is what a client PATCHes back; what was // derived from it travels alongside, as on a page. 'logo' => $this->logo, 'logo_media' => ImagePayload::make( $this->logo, $this->resource->relationLoaded('logoMedia') ? $this->resource->getRelation('logoMedia') : null, $this->name, ), 'website' => $this->website, 'position' => $this->position, 'projects_count' => $this->whenCounted('projects'), 'created_at' => $this->created_at?->toIso8601String(), 'updated_at' => $this->updated_at?->toIso8601String(), 'translations' => $this->when( in_array('translations', explode(',', (string) $request->query('with')), true), fn () => TranslatablePayload::all($this->resource, $this->translatable), ), ]; } }