*/ protected $allowedFields = ['code', 'native_name']; /** * @var string */ protected $returnType = Language::class; /** * @var bool */ protected $useSoftDeletes = false; /** * @var bool */ protected $useTimestamps = false; /** * @return array */ public function getLanguageOptions(): array { if (! ($options = cache('language_options'))) { $languages = $this->findAll(); $options = array_reduce( $languages, static function (array $result, Language $language): array { $result[$language->code] = $language->native_name; return $result; }, [], ); cache() ->save('language_options', $options, DECADE); } return $options; } }