2024-10-25 01:43:13 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modules\Nami\Components;
|
|
|
|
|
|
|
|
use App\Initialize\Actions\NamiLoginCheckAction;
|
|
|
|
use App\Setting\NamiSettings;
|
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
use Livewire\Component;
|
|
|
|
use Zoomyboy\LaravelNami\LoginException;
|
|
|
|
|
|
|
|
class SettingView extends Component
|
|
|
|
{
|
|
|
|
|
|
|
|
public $settingClass = NamiSettings::class;
|
|
|
|
public string $password = '';
|
|
|
|
public string $mglnr = '';
|
|
|
|
public string $default_group_id = '';
|
|
|
|
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'password' => 'required|string',
|
|
|
|
'default_group_id' => 'required',
|
|
|
|
'mglnr' => 'required',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function mount(): void
|
|
|
|
{
|
|
|
|
$this->mglnr = app(NamiSettings::class)->mglnr;
|
|
|
|
$this->default_group_id = app(NamiSettings::class)->default_group_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function save(): void
|
|
|
|
{
|
|
|
|
$validated = $this->validate();
|
|
|
|
try {
|
|
|
|
NamiLoginCheckAction::run([
|
|
|
|
'mglnr' => $this->mglnr,
|
|
|
|
'password' => $this->password,
|
|
|
|
]);
|
|
|
|
app(NamiSettings::class)->fill($validated)->save();
|
|
|
|
$this->dispatch('success', 'Einstellungen gespeichert.');
|
|
|
|
} catch (LoginException $e) {
|
|
|
|
throw ValidationException::withMessages([
|
|
|
|
'mglnr' => 'Login fehlgeschlagen.',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return <<<'HTML'
|
|
|
|
<x-page::setting-layout :active="$settingClass">
|
|
|
|
<x-slot:right>
|
|
|
|
<x-form::save-button form="namisettingform"></x-form::save-button>
|
|
|
|
</x-slot:right>
|
|
|
|
<form id="namisettingform" 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 deine Zugangsdaten zu NaMi anpassen, falls sich z.B. dein Passwort geändert hat.
|
|
|
|
</x-ui::setting-intro>
|
2024-10-25 01:43:13 +02:00
|
|
|
<x-form::text name="mglnr" wire:model="mglnr" label="Mitgliedsnummer"></x-form::text>
|
|
|
|
<x-form::text name="default_group_id" wire:model="default_group_id" label="Standard-Gruppierung"></x-form::text>
|
|
|
|
<x-form::text name="password" wire:model="password" label="Passwort" name="password" type="password"></x-form::text>
|
|
|
|
</form>
|
|
|
|
</x-page::setting-layout>
|
|
|
|
HTML;
|
|
|
|
}
|
|
|
|
}
|