Deploy Ladill Frontdesk / deploy (push) Successful in 2m46s
Sidebar settings and upgrade share one footer with consistent spacing. Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\User;
|
|
use App\Services\Frontdesk\OrganizationResolver;
|
|
use App\Services\Frontdesk\PlanService;
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
RateLimiter::for('kiosk-device', function (Request $request) {
|
|
$key = $request->route('token')
|
|
?? $request->header('X-Device-Token')
|
|
?? $request->ip();
|
|
|
|
return Limit::perMinute(30)->by((string) $key);
|
|
});
|
|
|
|
RateLimiter::for('qr-scan', fn (Request $request) => Limit::perMinute(20)->by($request->ip()));
|
|
|
|
RateLimiter::for('device-heartbeat', function (Request $request) {
|
|
return Limit::perMinute(60)->by((string) ($request->header('X-Device-Token') ?? $request->ip()));
|
|
});
|
|
|
|
View::composer('partials.sidebar', function ($view) {
|
|
/** @var User|null $user */
|
|
$user = auth()->user();
|
|
$planKey = 'free';
|
|
$isPro = false;
|
|
$isEnterprise = false;
|
|
$hasPaidPlan = false;
|
|
|
|
if ($user) {
|
|
$organization = app(OrganizationResolver::class)->resolveForUser($user);
|
|
if ($organization) {
|
|
$plans = app(PlanService::class);
|
|
$planKey = $plans->planKey($organization);
|
|
$isPro = $planKey === 'pro';
|
|
$isEnterprise = $planKey === 'enterprise';
|
|
$hasPaidPlan = $plans->hasPaidPlan($organization);
|
|
}
|
|
}
|
|
|
|
$view->with([
|
|
'planKey' => $planKey,
|
|
'isPro' => $isPro,
|
|
'isEnterprise' => $isEnterprise,
|
|
'hasPaidPlan' => $hasPaidPlan,
|
|
]);
|
|
});
|
|
|
|
View::composer(['partials.topbar'], function ($view) {
|
|
$view->with(\App\Support\MobileTopbar::resolve());
|
|
});
|
|
}
|
|
}
|