adrema/app/Setting/LocalSettings.php

50 lines
951 B
PHP

<?php
namespace App\Setting;
use Lorisleiva\Actions\ActionRequest;
use Spatie\LaravelSettings\Settings;
abstract class LocalSettings extends Settings
{
abstract public static function title(): string;
public function url(): string
{
return route('setting.view', ['settingGroup' => $this->group()]);
}
public function storeUrl(): string
{
return $this->url();
}
/**
* @return mixed
*/
public function data()
{
return [
'data' => $this->toArray(),
'meta' => [
'links' => [
'store' => $this->storeUrl(),
]
]
];
}
public function beforeSave(ActionRequest $request): void
{
return;
}
/**
* @return array<string, mixed>
*/
public function saveAttributes(ActionRequest $request): array
{
return $request->validated();
}
}