2023-11-16 10:52:57 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Module;
|
|
|
|
|
|
|
|
use App\Setting\Contracts\Storeable;
|
|
|
|
use App\Setting\LocalSettings;
|
2024-08-01 13:33:28 +02:00
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
use Lorisleiva\Actions\ActionRequest;
|
2023-11-16 10:52:57 +01:00
|
|
|
|
2024-08-01 11:32:14 +02:00
|
|
|
class ModuleSettings extends LocalSettings implements Storeable
|
2023-11-16 10:52:57 +01:00
|
|
|
{
|
|
|
|
/** @var array<int, string> */
|
|
|
|
public array $modules;
|
|
|
|
|
|
|
|
public static function group(): string
|
|
|
|
{
|
|
|
|
return 'module';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function title(): string
|
|
|
|
{
|
|
|
|
return 'Module';
|
|
|
|
}
|
|
|
|
|
2024-08-01 13:33:28 +02:00
|
|
|
public function hasModule(string $module): bool
|
2023-11-16 10:52:57 +01:00
|
|
|
{
|
2024-08-01 13:33:28 +02:00
|
|
|
return in_array($module, $this->modules);
|
2023-11-16 10:52:57 +01:00
|
|
|
}
|
|
|
|
|
2024-08-01 13:33:28 +02:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'modules' => 'present|array',
|
|
|
|
'modules.*' => ['string', Rule::in(Module::values())],
|
|
|
|
];
|
2023-11-16 10:52:57 +01:00
|
|
|
}
|
2024-08-01 11:17:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2024-08-01 18:25:25 +02:00
|
|
|
public function meta(): array
|
2024-08-01 11:17:49 +02:00
|
|
|
{
|
|
|
|
return [
|
2024-08-01 18:25:25 +02:00
|
|
|
...parent::meta(),
|
|
|
|
'modules' => Module::forSelect()
|
2024-08-01 11:17:49 +02:00
|
|
|
];
|
|
|
|
}
|
2023-11-16 10:52:57 +01:00
|
|
|
}
|