*/ public function toArray(Request $request): array { $locale = app()->getLocale(); return [ 'id' => $this->id, 'quote' => $this->getTranslation('quote', $locale), /* * Whether these are the words that were actually said. A quote * shown in a language it was not given in has been translated by * us, and the frontend can say so — "translated from Spanish" — * instead of pretending somebody phrased it that way. */ 'original_locale' => $this->original_locale, 'is_original' => $this->isOriginal($locale), 'author' => [ 'name' => $this->author_name, 'role' => $this->getTranslation('author_role', $locale, false) ?: null, 'avatar' => ImagePayload::make( $this->avatar, $this->resource->relationLoaded('avatarMedia') ? $this->resource->getRelation('avatarMedia') : null, $this->author_name, ), ], 'given_at' => $this->given_at?->toDateString(), 'client' => PublicClientResource::make($this->whenLoaded('client')), ]; } }