Tighten Care free tier and bill Pro/Enterprise per branch.
Deploy Ladill Care / deploy (push) Successful in 29s
Deploy Ladill Care / deploy (push) Successful in 29s
Free keeps core records, appointments, and basic workflows; Pro unlocks lab, pharmacy, billing, and Queue. Both paid tiers bill per branch with unlimited branches. Enterprise adds multi-dept workflows, analytics, AI-assisted healthcare integration, and priority support (not Afia).
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Services\Care\OrganizationResolver;
|
||||
use App\Services\Care\PlanService;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Blocks free-plan accounts from Pro modules (lab, pharmacy, billing, Queue integration).
|
||||
*/
|
||||
class EnsurePaidPlan
|
||||
{
|
||||
public function __construct(
|
||||
protected OrganizationResolver $organizations,
|
||||
protected PlanService $plans,
|
||||
) {}
|
||||
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$user = $request->user();
|
||||
if (! $user) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
$organization = $this->organizations->resolveForUser($user);
|
||||
if (! $organization || $this->plans->hasPaidPlan($organization)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if ($request->expectsJson() || $request->ajax()) {
|
||||
return response()->json([
|
||||
'message' => 'This feature requires Care Pro or Enterprise.',
|
||||
'upgrade_url' => route('care.pro.index'),
|
||||
], 402);
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('care.pro.index')
|
||||
->with('upsell', 'Lab, pharmacy, billing, and Queue integration are part of Care Pro. Upgrade to unlock them.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user