adrema/modules/Module/Components/SettingView.php

57 lines
1.8 KiB
PHP
Raw Normal View History

2024-10-14 20:25:11 +02:00
<?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">
2024-10-25 01:58:27 +02:00
<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>
2024-10-14 20:25:11 +02:00
@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;
}
}