57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Module\Components;
|
|
|
|
use App\Module\Module;
|
|
use Illuminate\Validation\Rule;
|
|
use Livewire\Component;
|
|
use Modules\Module\ModuleSettings;
|
|
|
|
class SettingView extends Component
|
|
{
|
|
|
|
public array $modules;
|
|
public array $all;
|
|
public $settingClass = ModuleSettings::class;
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'modules' => 'present|array',
|
|
'modules.*' => ['string', Rule::in(Module::values())],
|
|
];
|
|
}
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->modules = app(ModuleSettings::class)->modules;
|
|
$this->all = Module::forSelect();
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
app(ModuleSettings::class)->fill($this->validate())->save();
|
|
$this->dispatch('success', 'Einstellungen gespeichert.');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return <<<'HTML'
|
|
<x-page::setting-layout :active="$settingClass">
|
|
<x-slot:right>
|
|
<x-form::save-button form="modulesettingform"></x-form::save-button>
|
|
</x-slot:right>
|
|
<form id="modulesettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start"
|
|
wire:submit.prevent="save">
|
|
<x-ui::setting-intro class="col-span-full">
|
|
Hier kannst du Funktionen innerhalb von Adrema (Module) aktivieren oder deaktivieren und so den Funktionsumfang auf deine Bedürfnisse anpassen.
|
|
</x-ui::setting-intro>
|
|
@foreach ($all as $module)
|
|
<x-form::lever wire:model="modules" hint="lala" :value="$module['id']" name="modules" size="sm" :label="$module['name']"></x-form::lever>
|
|
@endforeach
|
|
</form>
|
|
</x-page::setting-layout>
|
|
HTML;
|
|
}
|
|
}
|