Deploy Ladill Care / deploy (push) Successful in 41s
Non-Enterprise orgs hitting /reports/assessments get the in-app plans upsell; CSV export redirects to View plans with an upsell flash. Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Care\Concerns;
|
|
|
|
use App\Services\Care\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.
|
|
*
|
|
* @param 'pro'|'enterprise' $planHint Which tier to highlight in pricing copy
|
|
*/
|
|
protected function proFeatureUpgradeView(
|
|
Request $request,
|
|
string $feature,
|
|
string $title,
|
|
string $description,
|
|
string $planHint = 'pro',
|
|
?string $upgradeBody = null,
|
|
): ?View {
|
|
$organization = $this->organization($request);
|
|
$plans = app(PlanService::class);
|
|
|
|
if ($plans->hasFeature($organization, $feature)) {
|
|
return null;
|
|
}
|
|
|
|
$isEnterprise = $planHint === 'enterprise';
|
|
|
|
return view('care.settings.pro-feature', [
|
|
'organization' => $organization,
|
|
'title' => $title,
|
|
'description' => $description,
|
|
'planLabel' => $isEnterprise ? 'Enterprise' : 'Pro',
|
|
'proPriceMinor' => $isEnterprise
|
|
? $plans->enterprisePricePerBranchMinor()
|
|
: $plans->proPricePerBranchMinor(),
|
|
'upgradeBody' => $upgradeBody,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 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('care.pro.index')
|
|
->with('upsell', $message);
|
|
}
|
|
}
|