55 lines
1.0 KiB
PHP
55 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Module;
|
|
|
|
use App\Setting\Contracts\Storeable;
|
|
use App\Setting\LocalSettings;
|
|
use Illuminate\Validation\Rule;
|
|
use Lorisleiva\Actions\ActionRequest;
|
|
|
|
class ModuleSettings extends LocalSettings implements Storeable
|
|
{
|
|
/** @var array<int, string> */
|
|
public array $modules;
|
|
|
|
public static function group(): string
|
|
{
|
|
return 'module';
|
|
}
|
|
|
|
public static function title(): string
|
|
{
|
|
return 'Module';
|
|
}
|
|
|
|
public function hasModule(string $module): bool
|
|
{
|
|
return in_array($module, $this->modules);
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'modules' => 'present|array',
|
|
'modules.*' => ['string', Rule::in(Module::values())],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function data(): array
|
|
{
|
|
return [
|
|
...parent::data(),
|
|
'meta' => [
|
|
...parent::data()['meta'],
|
|
'modules' => Module::forSelect(),
|
|
]
|
|
];
|
|
}
|
|
}
|