*/ protected function casts(): array { return [ 'is_published' => 'boolean', 'sort_order' => 'integer', ]; } /** * @param Builder $query */ public function scopePublished(Builder $query): void { $query->where('is_published', true)->orderBy('sort_order')->orderBy('id'); } /** * The testimonial in the visitor's language. * * @return array{id: int, quote: string, role: string, organization: string} */ public function localized(string $locale): array { $suffix = $locale === 'en' ? 'en' : 'id'; return [ 'id' => $this->id, 'quote' => $this->{"quote_{$suffix}"}, 'role' => $this->{"role_{$suffix}"}, 'organization' => $this->{"organization_{$suffix}"}, ]; } }