Limit Pro to 3 branches and leave Business unlimited.
Deploy Ladill POS / deploy (push) Successful in 2m15s

Enforce plan location caps in SubscriptionService, surface upgrade
copy on plans and branch settings, and cover the limits in tests.
This commit is contained in:
isaacclad
2026-07-15 15:24:51 +00:00
parent e2b608a506
commit 5e31bdf629
7 changed files with 142 additions and 7 deletions
@@ -55,7 +55,7 @@ class LocationController extends Controller
if (! $this->subscriptions->canAddLocation($account, $owner)) {
return redirect()->route('pos.pro.index')
->with('upsell', 'Multi-branch POS requires Ladill POS Pro or Business.');
->with('upsell', $this->subscriptions->locationLimitMessage($account));
}
$data = $request->validate([
+47 -3
View File
@@ -111,6 +111,32 @@ class SubscriptionService
return PosLocation::owned($ownerRef)->count();
}
/**
* Max branches for the account's plan. null = unlimited.
*/
public function maxLocations(User $user): ?int
{
if (! $this->gatingActive()) {
return null;
}
$key = $this->planKey($user);
if ($key === 'free') {
return (int) config('pos.free.max_locations', 1);
}
if ($key === ProSubscription::PLAN_ENTERPRISE) {
$max = config('pos.plans.enterprise.max_locations');
return $max === null ? null : (int) $max;
}
$max = config('pos.plans.pro.max_locations', 3);
return $max === null ? null : (int) $max;
}
public function canUseMultiLocation(User $user): bool
{
return $this->isPro($user);
@@ -118,11 +144,29 @@ class SubscriptionService
public function canAddLocation(User $user, string $ownerRef): bool
{
if (! $this->canUseMultiLocation($user)) {
return $this->locationCount($ownerRef) < (int) config('pos.free.max_locations', 1);
$max = $this->maxLocations($user);
if ($max === null) {
return true;
}
return true;
return $this->locationCount($ownerRef) < $max;
}
public function locationLimitMessage(User $user): string
{
$key = $this->planKey($user);
$max = $this->maxLocations($user);
if ($key === 'free') {
return 'Your Free plan allows 1 branch. Upgrade to Pro for up to 3 branches, or Business for unlimited.';
}
if ($key === ProSubscription::PLAN_PRO && $max !== null) {
return "Your Pro plan allows up to {$max} branches. Upgrade to Business for unlimited locations.";
}
return 'Branch limit reached for your current plan.';
}
public function canManageTeam(User $user): bool