Remove viewable interface
This commit is contained in:
parent
443fc484da
commit
617fd0ec44
|
@ -4,21 +4,15 @@ namespace App\Fileshare;
|
||||||
|
|
||||||
use App\Fileshare\Models\Fileshare;
|
use App\Fileshare\Models\Fileshare;
|
||||||
use App\Fileshare\Resources\FileshareResource;
|
use App\Fileshare\Resources\FileshareResource;
|
||||||
use App\Setting\Contracts\Viewable;
|
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
class FileshareSettings extends LocalSettings implements Viewable
|
class FileshareSettings extends LocalSettings
|
||||||
{
|
{
|
||||||
public static function group(): string
|
public static function group(): string
|
||||||
{
|
{
|
||||||
return 'fileshare';
|
return 'fileshare';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function slug(): string
|
|
||||||
{
|
|
||||||
return 'fileshare';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function title(): string
|
public static function title(): string
|
||||||
{
|
{
|
||||||
return 'Datei-Verbindungen';
|
return 'Datei-Verbindungen';
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
use App\Form\Actions\SettingStoreAction;
|
use App\Form\Actions\SettingStoreAction;
|
||||||
use App\Setting\Contracts\Viewable;
|
|
||||||
use App\Setting\Contracts\Storeable;
|
use App\Setting\Contracts\Storeable;
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
class FormSettings extends LocalSettings implements Viewable, Storeable
|
class FormSettings extends LocalSettings implements Storeable
|
||||||
{
|
{
|
||||||
public string $registerUrl;
|
public string $registerUrl;
|
||||||
public string $clearCacheUrl;
|
public string $clearCacheUrl;
|
||||||
|
@ -17,11 +16,6 @@ class FormSettings extends LocalSettings implements Viewable, Storeable
|
||||||
return 'form';
|
return 'form';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function slug(): string
|
|
||||||
{
|
|
||||||
return 'form';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function title(): string
|
public static function title(): string
|
||||||
{
|
{
|
||||||
return 'Formulare';
|
return 'Formulare';
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
|
|
||||||
namespace App\Invoice;
|
namespace App\Invoice;
|
||||||
|
|
||||||
use App\Setting\Contracts\Viewable;
|
|
||||||
use App\Setting\Contracts\Storeable;
|
use App\Setting\Contracts\Storeable;
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
class InvoiceSettings extends LocalSettings implements Viewable, Storeable
|
class InvoiceSettings extends LocalSettings implements Storeable
|
||||||
{
|
{
|
||||||
public string $from_long;
|
public string $from_long;
|
||||||
|
|
||||||
|
@ -35,11 +34,6 @@ class InvoiceSettings extends LocalSettings implements Viewable, Storeable
|
||||||
return 'bill';
|
return 'bill';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function slug(): string
|
|
||||||
{
|
|
||||||
return 'bill';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,24 +2,17 @@
|
||||||
|
|
||||||
namespace App\Mailgateway;
|
namespace App\Mailgateway;
|
||||||
|
|
||||||
use App\Mailgateway\Actions\IndexAction;
|
|
||||||
use App\Mailgateway\Models\Mailgateway;
|
use App\Mailgateway\Models\Mailgateway;
|
||||||
use App\Mailgateway\Resources\MailgatewayResource;
|
use App\Mailgateway\Resources\MailgatewayResource;
|
||||||
use App\Setting\Contracts\Viewable;
|
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
class MailgatewaySettings extends LocalSettings implements Viewable
|
class MailgatewaySettings extends LocalSettings
|
||||||
{
|
{
|
||||||
public static function group(): string
|
public static function group(): string
|
||||||
{
|
{
|
||||||
return 'mailgateway';
|
return 'mailgateway';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function slug(): string
|
|
||||||
{
|
|
||||||
return 'mailgateway';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function title(): string
|
public static function title(): string
|
||||||
{
|
{
|
||||||
return 'E-Mail-Verbindungen';
|
return 'E-Mail-Verbindungen';
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
|
|
||||||
namespace App\Module;
|
namespace App\Module;
|
||||||
|
|
||||||
use App\Setting\Contracts\Viewable;
|
|
||||||
use App\Setting\Contracts\Storeable;
|
use App\Setting\Contracts\Storeable;
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
class ModuleSettings extends LocalSettings implements Viewable, Storeable
|
class ModuleSettings extends LocalSettings implements Storeable
|
||||||
{
|
{
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
public array $modules;
|
public array $modules;
|
||||||
|
@ -16,11 +15,6 @@ class ModuleSettings extends LocalSettings implements Viewable, Storeable
|
||||||
return 'module';
|
return 'module';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function slug(): string
|
|
||||||
{
|
|
||||||
return 'module';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function title(): string
|
public static function title(): string
|
||||||
{
|
{
|
||||||
return 'Module';
|
return 'Module';
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
namespace App\Prevention;
|
namespace App\Prevention;
|
||||||
|
|
||||||
use App\Lib\Editor\EditorData;
|
use App\Lib\Editor\EditorData;
|
||||||
use App\Setting\Contracts\Viewable;
|
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
|
|
||||||
class PreventionSettings extends LocalSettings implements Viewable
|
class PreventionSettings extends LocalSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public EditorData $formmail;
|
public EditorData $formmail;
|
||||||
|
@ -16,11 +15,6 @@ class PreventionSettings extends LocalSettings implements Viewable
|
||||||
return 'prevention';
|
return 'prevention';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function slug(): string
|
|
||||||
{
|
|
||||||
return 'prevention';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function title(): string
|
public static function title(): string
|
||||||
{
|
{
|
||||||
return 'Prävention';
|
return 'Prävention';
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Setting\Actions;
|
namespace App\Setting\Actions;
|
||||||
|
|
||||||
use App\Setting\Contracts\Viewable;
|
use App\Setting\LocalSettings;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
@ -11,7 +11,7 @@ class ViewAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
public function handle(Viewable $settingGroup): Response
|
public function handle(LocalSettings $settingGroup): Response
|
||||||
{
|
{
|
||||||
session()->put('menu', 'setting');
|
session()->put('menu', 'setting');
|
||||||
session()->put('title', $settingGroup::title());
|
session()->put('title', $settingGroup::title());
|
||||||
|
|
|
@ -8,4 +8,6 @@ interface Storeable
|
||||||
* @return class-string
|
* @return class-string
|
||||||
*/
|
*/
|
||||||
public static function storeAction(): string;
|
public static function storeAction(): string;
|
||||||
|
|
||||||
|
public static function url(): string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Setting\Contracts;
|
|
||||||
|
|
||||||
interface Viewable
|
|
||||||
{
|
|
||||||
public static function url(): string;
|
|
||||||
|
|
||||||
public static function title(): string;
|
|
||||||
|
|
||||||
public static function group(): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function viewData(): array;
|
|
||||||
}
|
|
|
@ -6,12 +6,15 @@ use Spatie\LaravelSettings\Settings;
|
||||||
|
|
||||||
abstract class LocalSettings extends Settings
|
abstract class LocalSettings extends Settings
|
||||||
{
|
{
|
||||||
abstract public static function slug(): string;
|
|
||||||
|
|
||||||
abstract public static function title(): string;
|
abstract public static function title(): string;
|
||||||
|
|
||||||
public static function url(): string
|
public static function url(): string
|
||||||
{
|
{
|
||||||
return '/setting/'.static::slug();
|
return '/setting/' . static::group();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
abstract public function viewData(): array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,12 @@
|
||||||
namespace App\Setting;
|
namespace App\Setting;
|
||||||
|
|
||||||
use App\Group;
|
use App\Group;
|
||||||
use App\Nami\Actions\SettingIndexAction;
|
|
||||||
use App\Nami\Actions\SettingSaveAction;
|
use App\Nami\Actions\SettingSaveAction;
|
||||||
use App\Setting\Contracts\Viewable;
|
|
||||||
use App\Setting\Contracts\Storeable;
|
use App\Setting\Contracts\Storeable;
|
||||||
use Zoomyboy\LaravelNami\Api;
|
use Zoomyboy\LaravelNami\Api;
|
||||||
use Zoomyboy\LaravelNami\Nami;
|
use Zoomyboy\LaravelNami\Nami;
|
||||||
|
|
||||||
class NamiSettings extends LocalSettings implements Viewable, Storeable
|
class NamiSettings extends LocalSettings implements Storeable
|
||||||
{
|
{
|
||||||
public int $mglnr;
|
public int $mglnr;
|
||||||
|
|
||||||
|
@ -36,11 +34,6 @@ class NamiSettings extends LocalSettings implements Viewable, Storeable
|
||||||
return Group::firstWhere('nami_id', $this->default_group_id);
|
return Group::firstWhere('nami_id', $this->default_group_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function slug(): string
|
|
||||||
{
|
|
||||||
return 'nami';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function storeAction(): string
|
public static function storeAction(): string
|
||||||
{
|
{
|
||||||
return SettingSaveAction::class;
|
return SettingSaveAction::class;
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Setting;
|
||||||
|
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use App\Setting\Contracts\Storeable;
|
use App\Setting\Contracts\Storeable;
|
||||||
use App\Setting\Contracts\Viewable;
|
|
||||||
use Illuminate\Routing\Router;
|
use Illuminate\Routing\Router;
|
||||||
|
|
||||||
class SettingFactory
|
class SettingFactory
|
||||||
|
@ -15,18 +14,18 @@ class SettingFactory
|
||||||
private array $settings = [];
|
private array $settings = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class-string $setting
|
* @param class-string<LocalSettings> $setting
|
||||||
*/
|
*/
|
||||||
public function register(string $setting): void
|
public function register(string $setting): void
|
||||||
{
|
{
|
||||||
$this->settings[] = $setting;
|
$this->settings[] = $setting;
|
||||||
|
|
||||||
if (new $setting() instanceof Storeable) {
|
if (new $setting instanceof Storeable) {
|
||||||
app(Router::class)->middleware(['web', 'auth:web'])->post($setting::url(), $setting::storeAction());
|
$this->registerStoreRoute(new $setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 === count($this->settings)) {
|
if (1 === count($this->settings)) {
|
||||||
app(Router::class)->redirect('/setting', '/setting/' . $setting::slug());
|
app(Router::class)->redirect('/setting', '/setting/' . $setting::group());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,10 +42,15 @@ class SettingFactory
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolveGroupName(string $name): Viewable
|
public function resolveGroupName(string $name): LocalSettings
|
||||||
{
|
{
|
||||||
$settingClass = collect($this->settings)->filter(fn ($setting) => new $setting() instanceof Viewable)->first(fn ($setting) => $setting::group() === $name);
|
$settingClass = collect($this->settings)->first(fn ($setting) => $setting::group() === $name);
|
||||||
|
|
||||||
return app($settingClass);
|
return app($settingClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function registerStoreRoute(Storeable $setting): void
|
||||||
|
{
|
||||||
|
app(Router::class)->middleware(['web', 'auth:web'])->post($setting::url(), $setting::storeAction());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue