*/ public array $translatable = ['subject', 'body']; protected function casts(): array { return ['position' => 'integer']; } /** * @param Builder<$this> $query * @return Builder<$this> */ public function scopeFor(Builder $query, ApplicationKind $kind): Builder { return $query ->where(fn (Builder $q) => $q->whereNull('kind')->orWhere('kind', $kind->value)) ->orderBy('position') ->orderBy('name'); } /** * Subject and body for one submission, in its language. * * @return array{subject: string, body: string} */ public function renderFor(Application $application, ?User $sender = null): array { $values = [$application->name, $application->subject(), $sender?->name ?? (string) config('app.name')]; return [ 'subject' => str_replace(self::PLACEHOLDERS, $values, (string) $this->getTranslation('subject', $application->locale)), 'body' => str_replace(self::PLACEHOLDERS, $values, (string) $this->getTranslation('body', $application->locale)), ]; } }