LocaleSettings.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Settings;
  3. use Spatie\LaravelSettings\Settings;
  4. class LocaleSettings extends Settings
  5. {
  6. public ?string $available;
  7. public bool $clients_can_change;
  8. public ?string $datatables;
  9. public string $default;
  10. public bool $dynamic;
  11. public static function group(): string
  12. {
  13. return 'locale';
  14. }
  15. /**
  16. * Summary of validations array
  17. * @return array<string, string>
  18. */
  19. public static function getValidations()
  20. {
  21. return [
  22. 'available' => 'array|required',
  23. 'clients_can_change' => 'nullable|string',
  24. 'datatables' => 'nullable|string',
  25. 'default' => 'required|in:' . implode(',', config('app.available_locales')),
  26. 'dynamic' => 'nullable|string',
  27. ];
  28. }
  29. /**
  30. * Summary of optionTypes
  31. * Only used for the settings page
  32. * @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
  33. */
  34. public static function getOptionInputData()
  35. {
  36. return [
  37. 'category_icon' => 'fas fa-globe',
  38. 'available' => [
  39. 'label' => 'Available Locales',
  40. 'type' => 'multiselect',
  41. 'description' => 'The locales that are available for the user to choose from.',
  42. 'options' => config('app.available_locales'),
  43. ],
  44. 'clients_can_change' => [
  45. 'label' => 'Clients Can Change',
  46. 'type' => 'boolean',
  47. 'description' => 'Whether clients can change their locale.',
  48. ],
  49. 'datatables' => [
  50. 'label' => 'Datatables Locale',
  51. 'type' => 'string',
  52. 'description' => 'The datatables lang-code. <br><strong>Example:</strong> en-gb, fr_fr, de_de<br>More Information: <a href="https://datatables.net/plug-ins/i18n/">https://datatables.net/plug-ins/i18n/</a>',
  53. ],
  54. 'default' => [
  55. 'label' => 'Default Locale',
  56. 'type' => 'select',
  57. 'description' => 'The default locale to use.',
  58. 'options' => config('app.available_locales'),
  59. 'identifier' => 'display'
  60. ],
  61. 'dynamic' => [
  62. 'label' => 'Dynamic Locale',
  63. 'type' => 'boolean',
  64. 'description' => 'Whether to use the dynamic locale.',
  65. ],
  66. ];
  67. }
  68. }