Deploy Ladill POS / deploy (push) Successful in 43s
Wallet-backed Pro unlocks unlimited products, restaurant mode, catalog imports, and ecosystem sync features. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
821 B
PHP
30 lines
821 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Services\Pos\SubscriptionService;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class EnsurePro
|
|
{
|
|
public function __construct(private readonly SubscriptionService $subscriptions) {}
|
|
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
$user = ladill_account() ?? $request->user();
|
|
|
|
if ($user && $this->subscriptions->isPro($user)) {
|
|
return $next($request);
|
|
}
|
|
|
|
if ($request->expectsJson()) {
|
|
return response()->json(['message' => 'This feature requires Ladill POS Pro.'], 402);
|
|
}
|
|
|
|
return redirect()->route('pos.pro.index')
|
|
->with('upsell', 'That feature is part of Ladill POS Pro — subscribe to unlock it.');
|
|
}
|
|
}
|