Files
Additional/app/Providers/AppServiceProvider.php
twotalesanimation 66862df44b fix: Use flexible type check for is_admin authorization gate
Change strict equality check (=== true) to loose check that works with
both integer 1 and boolean true values.
2026-01-02 21:10:26 +02:00

41 lines
1.0 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
if (config('app.env') === 'production' || request()->server('HTTP_X_FORWARDED_PROTO') === 'https') {
URL::forceScheme('https');
}
// Share cart count with all views
View::composer('*', function ($view) {
$cartCount = session('cart') ? count(session('cart')) : 0;
$view->with('cartCount', $cartCount);
});
// Authorization gates
\Illuminate\Support\Facades\Gate::define('access-ops', function ($user) {
// Allow admin users to access ops (flexible type check)
return $user && $user->is_admin;
});
}
}