*/ public function toArray(Request $request): array { $locale = app()->getLocale(); return [ 'id' => $this->id, 'name' => $this->name, 'slug' => $this->slug, ...TranslatablePayload::resolve($this->resource, ['headline', 'bio'], $locale), // A portrait's description is the person's name, so there is no // field to fill in and no way to get it wrong. 'avatar' => ImagePayload::make( $this->avatar, $this->resource->relationLoaded('avatarMedia') ? $this->resource->getRelation('avatarMedia') : null, $this->avatarAlt(), ), 'github_username' => $this->github_username, 'links' => (object) ($this->links ?? []), 'is_founder' => $this->is_founder, // Former members stay on the site with their history intact; the // frontend decides how to present them. 'is_current' => $this->left_at === null, 'joined_at' => $this->joined_at?->toDateString(), 'left_at' => $this->left_at?->toDateString(), 'role' => $this->whenPivotLoaded('member_project', fn () => $this->pivot->role), 'technologies' => PublicTechnologyResource::collection($this->whenLoaded('technologies')), 'projects' => PublicProjectResource::collection($this->whenLoaded('projects')), 'alternates' => $this->memberAlternates(), 'path' => SiteUrls::path('member', $locale, $this->slug), ]; } /** * A member's slug is a single string rather than a translated map, so the * same slug is valid in every locale — only the path prefix changes. * * @return array */ protected function memberAlternates(): array { return collect(array_keys(config('locales.supported'))) ->mapWithKeys(fn (string $locale) => [ $locale => SiteUrls::path('member', $locale, $this->slug), ]) ->all(); } }