43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Services\SettingsService;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class SettingsServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton(SettingsService::class);
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
// Settings nur laden wenn die Tabelle existiert (z.B. vor Migration schützen)
|
|
if (!$this->app->runningInConsole() && Schema::hasTable('settings')) {
|
|
$settings = $this->app->make(SettingsService::class)->all();
|
|
|
|
View::share('appSettings', $settings);
|
|
} else {
|
|
View::share('appSettings', [
|
|
'site_name' => config('app.name'),
|
|
'site_logo' => '',
|
|
'button_color' => '#4f46e5',
|
|
'theme_mode' => 'light',
|
|
]);
|
|
}
|
|
|
|
// Update-Badge: aus Cache lesen (kein HTTP-Request auf jeder Seite)
|
|
if (!$this->app->runningInConsole()) {
|
|
$updateAvailableVersion = Cache::get('app_update_available', null);
|
|
View::share('navUpdateAvailable', $updateAvailableVersion ?: false);
|
|
} else {
|
|
View::share('navUpdateAvailable', false);
|
|
}
|
|
}
|
|
}
|