Files
Additional/app/Providers/AppServiceProvider.php
T
twotalesanimation 4a8b4ddac2 fix: Double-charged shipping fee in Yoco payment + ops staff access
1. Fix Yoco payment amount calculation: order->total already includes
   shipping_fee, so don't add it again. Was charging 2x shipping.

2. Add authorization gate for ops staff access: users with is_admin=true
   can now access the ops page by scanning QR codes.
2026-01-02 21:07:21 +02:00

41 lines
1023 B
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
return $user->is_admin === true;
});
}
}