all()[$slot->value] ?? null; } public function flush(): void { Cache::forget(self::CACHE_KEY); } /** * @return array */ private function all(): array { return Cache::rememberForever(self::CACHE_KEY, function (): array { if (! Schema::hasTable('email_templates')) { return []; } return EmailTemplate::query()->get() ->mapWithKeys(fn (EmailTemplate $template): array => [ $template->slot => ['subject' => $template->subject, 'body' => $template->body], ]) ->all(); }); } }