2023-02-02 15:45:17 +00:00
|
|
|
<?php
|
|
|
|
|
2023-02-06 20:16:54 +00:00
|
|
|
namespace App\Settings;
|
2023-02-02 15:45:17 +00:00
|
|
|
|
|
|
|
use Spatie\LaravelSettings\Settings;
|
|
|
|
|
|
|
|
class LocaleSettings extends Settings
|
|
|
|
{
|
2023-03-30 14:21:31 +00:00
|
|
|
public ?string $available;
|
2023-04-02 17:57:28 +00:00
|
|
|
public bool $clients_can_change;
|
2023-03-30 14:21:31 +00:00
|
|
|
public ?string $datatables;
|
2023-02-02 15:45:17 +00:00
|
|
|
public string $default;
|
2023-04-02 17:57:28 +00:00
|
|
|
public bool $dynamic;
|
2023-02-09 21:34:34 +00:00
|
|
|
|
2023-02-02 15:45:17 +00:00
|
|
|
public static function group(): string
|
|
|
|
{
|
|
|
|
return 'locale';
|
|
|
|
}
|
2023-02-09 21:34:34 +00:00
|
|
|
|
2023-02-09 23:31:27 +00:00
|
|
|
/**
|
|
|
|
* Summary of validations array
|
|
|
|
* @return array<string, string>
|
|
|
|
*/
|
|
|
|
public static function getValidations()
|
|
|
|
{
|
|
|
|
return [
|
2023-07-31 13:01:32 +00:00
|
|
|
'available' => 'array|required',
|
2023-05-08 12:42:46 +00:00
|
|
|
'clients_can_change' => 'nullable|string',
|
2023-02-09 23:31:27 +00:00
|
|
|
'datatables' => 'nullable|string',
|
2023-03-30 14:21:31 +00:00
|
|
|
'default' => 'required|in:' . implode(',', config('app.available_locales')),
|
2023-05-08 12:42:46 +00:00
|
|
|
'dynamic' => 'nullable|string',
|
2023-02-09 23:31:27 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-02-09 21:34:34 +00:00
|
|
|
/**
|
|
|
|
* Summary of optionTypes
|
|
|
|
* Only used for the settings page
|
|
|
|
* @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
|
|
|
|
*/
|
|
|
|
public static function getOptionInputData()
|
|
|
|
{
|
|
|
|
return [
|
2023-02-20 12:44:06 +00:00
|
|
|
'category_icon' => 'fas fa-globe',
|
2023-02-09 21:34:34 +00:00
|
|
|
'available' => [
|
|
|
|
'label' => 'Available Locales',
|
|
|
|
'type' => 'multiselect',
|
|
|
|
'description' => 'The locales that are available for the user to choose from.',
|
|
|
|
'options' => config('app.available_locales'),
|
|
|
|
],
|
|
|
|
'clients_can_change' => [
|
|
|
|
'label' => 'Clients Can Change',
|
|
|
|
'type' => 'boolean',
|
|
|
|
'description' => 'Whether clients can change their locale.',
|
|
|
|
],
|
|
|
|
'datatables' => [
|
|
|
|
'label' => 'Datatables Locale',
|
|
|
|
'type' => 'string',
|
|
|
|
'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>',
|
|
|
|
],
|
|
|
|
'default' => [
|
|
|
|
'label' => 'Default Locale',
|
|
|
|
'type' => 'select',
|
|
|
|
'description' => 'The default locale to use.',
|
|
|
|
'options' => config('app.available_locales'),
|
2023-06-04 14:08:22 +00:00
|
|
|
'identifier' => 'display'
|
2023-02-09 21:34:34 +00:00
|
|
|
],
|
|
|
|
'dynamic' => [
|
|
|
|
'label' => 'Dynamic Locale',
|
|
|
|
'type' => 'boolean',
|
|
|
|
'description' => 'Whether to use the dynamic locale.',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|