mivita/app/Providers/AppServiceProvider.php
2025-08-12 18:01:59 +02:00

57 lines
1.6 KiB
PHP
Executable file

<?php
namespace App\Providers;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\URL;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
if ($this->app->environment('production')) {
URL::forceScheme('https');
}
// Domain-bewusster View Composer für user_shop
\View::composer('*', function ($view) {
try {
$context = app(\App\Domain\DomainContext::class);
// Für die Main-Domain: user_shop immer auf null setzen
if ($context->type === 'main') {
$view->with('user_shop', null);
} else {
// Für alle anderen Domains: normales Verhalten
$userShop = $context->userShop ?? \App\Services\Util::getUserShop();
$view->with('user_shop', $userShop);
}
} catch (\Exception $e) {
// Fallback bei Fehlern
$view->with('user_shop', \App\Services\Util::getUserShop());
}
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
if ($this->app->environment() !== 'production') {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
// ...
}
}