Add validation attributes to nami field
This commit is contained in:
parent
10b26175a6
commit
1d70582275
|
@ -5,6 +5,7 @@ namespace Modules\Nami\Components;
|
||||||
use App\Initialize\Actions\NamiLoginCheckAction;
|
use App\Initialize\Actions\NamiLoginCheckAction;
|
||||||
use App\Setting\NamiSettings;
|
use App\Setting\NamiSettings;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Livewire\Attributes\Validate;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Zoomyboy\LaravelNami\LoginException;
|
use Zoomyboy\LaravelNami\LoginException;
|
||||||
|
|
||||||
|
@ -12,18 +13,13 @@ class SettingView extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
public $settingClass = NamiSettings::class;
|
public $settingClass = NamiSettings::class;
|
||||||
public string $password = '';
|
|
||||||
public string $mglnr = '';
|
|
||||||
public string $default_group_id = '';
|
|
||||||
|
|
||||||
public function rules(): array
|
#[Validate('required|string')]
|
||||||
{
|
public string $password = '';
|
||||||
return [
|
#[Validate('required|string')]
|
||||||
'password' => 'required|string',
|
public string $mglnr = '';
|
||||||
'default_group_id' => 'required',
|
#[Validate('required|string')]
|
||||||
'mglnr' => 'required',
|
public string $default_group_id = '';
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mount(): void
|
public function mount(): void
|
||||||
{
|
{
|
||||||
|
@ -35,10 +31,7 @@ class SettingView extends Component
|
||||||
{
|
{
|
||||||
$validated = $this->validate();
|
$validated = $this->validate();
|
||||||
try {
|
try {
|
||||||
NamiLoginCheckAction::run([
|
NamiLoginCheckAction::run($this->only(['mglnr', 'password']));
|
||||||
'mglnr' => $this->mglnr,
|
|
||||||
'password' => $this->password,
|
|
||||||
]);
|
|
||||||
app(NamiSettings::class)->fill($validated)->save();
|
app(NamiSettings::class)->fill($validated)->save();
|
||||||
$this->dispatch('success', 'Einstellungen gespeichert.');
|
$this->dispatch('success', 'Einstellungen gespeichert.');
|
||||||
} catch (LoginException $e) {
|
} catch (LoginException $e) {
|
||||||
|
|
Loading…
Reference in New Issue