adrema/app/Module/ModuleSettings.php

55 lines
1.0 KiB
PHP
Raw Normal View History

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
*/
public function data(): array
2024-08-01 11:17:49 +02:00
{
return [
...parent::data(),
'meta' => [
...parent::data()['meta'],
'modules' => Module::forSelect(),
]
2024-08-01 11:17:49 +02:00
];
}
2023-11-16 10:52:57 +01:00
}