2022-02-19 15:18:24 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Setting;
|
|
|
|
|
2023-02-26 18:48:34 +01:00
|
|
|
use App\Group;
|
2023-10-31 00:11:32 +01:00
|
|
|
use App\Nami\Actions\SettingIndexAction;
|
|
|
|
use App\Nami\Actions\SettingSaveAction;
|
2024-08-01 10:25:48 +02:00
|
|
|
use App\Setting\Contracts\Viewable;
|
2023-10-31 00:11:32 +01:00
|
|
|
use App\Setting\Contracts\Storeable;
|
2022-02-19 18:06:07 +01:00
|
|
|
use Zoomyboy\LaravelNami\Api;
|
|
|
|
use Zoomyboy\LaravelNami\Nami;
|
2022-02-19 15:18:24 +01:00
|
|
|
|
2024-08-01 10:25:48 +02:00
|
|
|
class NamiSettings extends LocalSettings implements Viewable, Storeable
|
2022-02-19 15:18:24 +01:00
|
|
|
{
|
|
|
|
public int $mglnr;
|
|
|
|
|
|
|
|
public string $password;
|
|
|
|
|
2022-05-01 21:00:15 +02:00
|
|
|
public int $default_group_id;
|
|
|
|
|
2023-05-08 15:11:16 +02:00
|
|
|
/** @var array<string, string> */
|
|
|
|
public array $search_params;
|
|
|
|
|
2022-02-19 15:18:24 +01:00
|
|
|
public static function group(): string
|
|
|
|
{
|
|
|
|
return 'nami';
|
|
|
|
}
|
|
|
|
|
2022-02-19 18:06:07 +01:00
|
|
|
public function login(): Api
|
|
|
|
{
|
|
|
|
return Nami::login($this->mglnr, $this->password);
|
|
|
|
}
|
2023-02-26 18:48:34 +01:00
|
|
|
|
|
|
|
public function localGroup(): ?Group
|
|
|
|
{
|
|
|
|
return Group::firstWhere('nami_id', $this->default_group_id);
|
|
|
|
}
|
2023-10-31 00:11:32 +01:00
|
|
|
|
|
|
|
public static function slug(): string
|
|
|
|
{
|
|
|
|
return 'nami';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function storeAction(): string
|
|
|
|
{
|
|
|
|
return SettingSaveAction::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function title(): string
|
|
|
|
{
|
|
|
|
return 'NaMi-Login';
|
|
|
|
}
|
2024-08-01 11:17:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
public function viewData(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'data' => [
|
|
|
|
'mglnr' => $this->mglnr,
|
|
|
|
'password' => '',
|
|
|
|
'default_group_id' => $this->default_group_id,
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
2022-02-19 15:18:24 +01:00
|
|
|
}
|