detailed = $detailed; return $this; } /** * @return array */ public function toArray(Request $request): array { $locale = app()->getLocale(); return [ 'id' => $this->id, 'locale' => $locale, ...TranslatablePayload::resolve($this->resource, ['title', 'slug', 'tagline'], $locale), 'icon' => $this->icon, 'is_featured' => $this->is_featured, 'position' => $this->position, 'updated_at' => $this->updated_at?->toIso8601String(), $this->mergeWhen($this->detailed, fn () => TranslatablePayload::resolve( $this->resource, ['description', 'meta_title', 'meta_description'], $locale, )), // The work that backs the offer. Without it a service is a // promise, which is why it travels with it rather than being // something the frontend has to go and ask for. 'projects' => PublicProjectResource::collection($this->whenLoaded('projects')), 'technologies' => PublicTechnologyResource::collection($this->whenLoaded('technologies')), 'testimonials' => PublicTestimonialResource::collection($this->whenLoaded('testimonials')), 'alternates' => SiteUrls::alternates($this->resource, 'service'), 'path' => SiteUrls::alternates($this->resource, 'service')[$locale] ?? null, ]; } }