Files
Atomcms-edit/app/Http/Middleware/InjectPwaMeta.php
T
2026-05-09 17:32:17 +02:00

32 lines
971 B
PHP
Executable File

<?php
namespace App\Http\Middleware;
use App\Models\Miscellaneous\WebsiteSetting;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class InjectPwaMeta
{
public function handle(Request $request, Closure $next): Response
{
$pwaEnabled = WebsiteSetting::where('key', 'pwa_enabled')->first()?->value === '1';
if ($pwaEnabled) {
$config = [
'name' => WebsiteSetting::where('key', 'pwa_name')->first()?->value ?? 'Epicnabbo',
'short_name' => WebsiteSetting::where('key', 'pwa_short_name')->first()?->value ?? 'Epicnabbo',
'theme_color' => WebsiteSetting::where('key', 'pwa_theme_color')->first()?->value ?? '#eeb425',
];
view()->share('pwa_enabled', true);
view()->share('pwa_config', $config);
} else {
view()->share('pwa_enabled', false);
}
return $next($request);
}
}