Deploy Ladill Care / deploy (push) Successful in 1m25s
Free plans keep a single setup branch but get an upgrade screen for Branches; Pro/Enterprise unlock multi-branch management via plan features.
54 lines
1.4 KiB
PHP
54 lines
1.4 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.
|
|
*/
|
|
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('care.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('care.pro.index')
|
|
->with('upsell', $message);
|
|
}
|
|
}
|