- Migration: settings table with key (unique), value (text), timestamps - Model: Setting with static get/set helpers using DB upsert - Controller: SettingsController with index (Inertia) and update (JSON) - Vue: Settings page with 4 macro fields, auto-save on blur - Navigation: Einstellungen link in desktop + mobile nav after API-Log - Shared props: macroSettings added to HandleInertiaRequests - Integration: ProExportService injects macro into COPYRIGHT group slides - Gracefully skips macro injection when settings empty/null
59 lines
1.7 KiB
PHP
59 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\CtsSyncLog;
|
|
use App\Models\Setting;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Middleware;
|
|
|
|
class HandleInertiaRequests extends Middleware
|
|
{
|
|
/**
|
|
* The root template that is loaded on the first page visit.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $rootView = 'app';
|
|
|
|
/**
|
|
* Determine the current asset version.
|
|
*/
|
|
public function version(Request $request): ?string
|
|
{
|
|
return parent::version($request);
|
|
}
|
|
|
|
/**
|
|
* Define the props that are shared by default.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function share(Request $request): array
|
|
{
|
|
return [
|
|
...parent::share($request),
|
|
'auth' => [
|
|
'user' => $request->user() ? [
|
|
'id' => $request->user()->id,
|
|
'name' => $request->user()->name,
|
|
'email' => $request->user()->email,
|
|
'avatar' => $request->user()->avatar,
|
|
] : null,
|
|
],
|
|
'flash' => [
|
|
'success' => $request->session()->get('success'),
|
|
'error' => $request->session()->get('error'),
|
|
],
|
|
'last_synced_at' => CtsSyncLog::latest()->first()?->synced_at,
|
|
'app_name' => config('app.name'),
|
|
'macroSettings' => [
|
|
'name' => Setting::get('macro_name'),
|
|
'uuid' => Setting::get('macro_uuid'),
|
|
'collectionName' => Setting::get('macro_collection_name', '--MAIN--'),
|
|
'collectionUuid' => Setting::get('macro_collection_uuid', '8D02FC57-83F8-4042-9B90-81C229728426'),
|
|
],
|
|
];
|
|
}
|
|
}
|