Files
ladill-queue/app/Http/Controllers/Qms/Concerns/RequiresPlanFeature.php
T
isaacclad 26c9edc131
Deploy Ladill Queue / deploy (push) Successful in 50s
Nest Branches and Team under Settings as Pro features.
Match Frontdesk: settings cards and nested routes, Pro-gated access,
and legacy /admin redirects to /settings/branches and /settings/team.
2026-07-16 09:48:32 +00:00

54 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers\Qms\Concerns;
use App\Services\Qms\PlanService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
trait RequiresPlanFeature
{
/**
* For page views: return an upgrade screen when the org lacks the feature.
*/
protected function proFeatureUpgradeView(
Request $request,
string $feature,
string $title,
string $description,
): ?View {
$organization = $this->organization($request);
$plans = app(PlanService::class);
if ($plans->hasFeature($organization, $feature)) {
return null;
}
return view('qms.settings.pro-feature', [
'organization' => $organization,
'title' => $title,
'description' => $description,
'proPriceMinor' => $plans->proPricePerBranchMinor(),
]);
}
/**
* For mutations: redirect free-plan orgs to the plans page.
*/
protected function denyWithoutFeature(
Request $request,
string $feature,
string $message,
): ?RedirectResponse {
$organization = $this->organization($request);
if (app(PlanService::class)->hasFeature($organization, $feature)) {
return null;
}
return redirect()
->route('qms.pro.index')
->with('error', $message);
}
}