Просмотр файла app/Repositories/SettingRepository.php

Размер файла: 674B
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Repositories;
  6.  
  7. use App\Models\Setting;
  8.  
  9. class SettingRepository implements RepositoryInterface
  10. {
  11. /**
  12. * Get setting
  13. *
  14. * @return array
  15. */
  16. public function getSettings(): array
  17. {
  18. $settings = Setting::query()
  19. ->get()
  20. ->pluck('value', 'name');
  21.  
  22. return array_map(static function ($value) {
  23. if (is_numeric($value)) {
  24. return ! str_contains($value, '.') ? (int) $value : (float) $value;
  25. }
  26.  
  27. if ($value === '') {
  28. return null;
  29. }
  30.  
  31. return $value;
  32. }, $settings);
  33. }
  34. }