adrema/modules/Form/Components/SettingView.php

54 lines
1.7 KiB
PHP

<?php
namespace Modules\Form\Components;
use App\Form\FormSettings;
use Livewire\Component;
class SettingView extends Component
{
public string $clearCacheUrl;
public string $registerUrl;
public $settingClass = FormSettings::class;
public function rules(): array
{
return [
'clearCacheUrl' => '',
'registerUrl' => '',
];
}
public function mount(): void
{
$this->registerUrl = app(FormSettings::class)->registerUrl;
$this->clearCacheUrl = app(FormSettings::class)->clearCacheUrl;
}
public function save(): void
{
app(FormSettings::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="formsettingform"></x-form::save-button>
</x-slot:right>
<form id="formsettingform" 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 Einstellungen für Anmeldeformulare setzen.
</x-ui::setting-intro>
<x-form::text name="register_url" wire:model="registerUrl" label="Formular-Link"></x-form::text>
<x-form::text name="clear_cache_url" wire:model="clearCacheUrl" label="Frontend-Cache-Url"></x-form::text>
</form>
</x-page::setting-layout>
HTML;
}
}