Move Branches and Team into Settings as Pro features.
Deploy Ladill Frontdesk / deploy (push) Successful in 48s
Deploy Ladill Frontdesk / deploy (push) Successful in 48s
Gate multi-branch and team management behind paid plans, nest their routes under Settings, and remove them from the sidebar Administration section.
This commit is contained in:
@@ -3,19 +3,36 @@
|
||||
namespace App\Http\Controllers\Frontdesk;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Frontdesk\Concerns\RequiresPlanFeature;
|
||||
use App\Http\Controllers\Frontdesk\Concerns\ScopesToAccount;
|
||||
use App\Models\Branch;
|
||||
use App\Services\Frontdesk\PlanService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class BranchController extends Controller
|
||||
{
|
||||
use RequiresPlanFeature;
|
||||
use ScopesToAccount;
|
||||
|
||||
private const FEATURE = 'branches';
|
||||
|
||||
private const UPGRADE_MESSAGE = 'Multi-branch management requires Frontdesk Pro.';
|
||||
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$this->authorizeAbility($request, 'admin.branches.view');
|
||||
|
||||
if ($upgrade = $this->proFeatureUpgradeView(
|
||||
$request,
|
||||
self::FEATURE,
|
||||
'Branches',
|
||||
'Manage locations, buildings, and reception desks with Frontdesk Pro. Free plans include one branch created during setup.',
|
||||
)) {
|
||||
return $upgrade;
|
||||
}
|
||||
|
||||
$organization = $this->organization($request);
|
||||
|
||||
$branches = Branch::owned($this->ownerRef($request))
|
||||
@@ -36,14 +53,29 @@ class BranchController extends Controller
|
||||
public function create(Request $request): View
|
||||
{
|
||||
$this->authorizeAbility($request, 'admin.branches.manage');
|
||||
|
||||
if ($upgrade = $this->proFeatureUpgradeView(
|
||||
$request,
|
||||
self::FEATURE,
|
||||
'Branches',
|
||||
'Add and manage multiple locations with Frontdesk Pro.',
|
||||
)) {
|
||||
return $upgrade;
|
||||
}
|
||||
|
||||
return view('frontdesk.admin.branches.create', ['organization' => $this->organization($request)]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->authorizeAbility($request, 'admin.branches.manage');
|
||||
|
||||
if ($deny = $this->denyWithoutFeature($request, self::FEATURE, self::UPGRADE_MESSAGE)) {
|
||||
return $deny;
|
||||
}
|
||||
|
||||
$organization = $this->organization($request);
|
||||
$plans = app(\App\Services\Frontdesk\PlanService::class);
|
||||
$plans = app(PlanService::class);
|
||||
|
||||
$currentCount = Branch::owned($this->ownerRef($request))
|
||||
->where('organization_id', $organization->id)
|
||||
@@ -75,6 +107,15 @@ class BranchController extends Controller
|
||||
$this->authorizeAbility($request, 'admin.branches.manage');
|
||||
$this->authorizeOwner($request, $branch);
|
||||
|
||||
if ($upgrade = $this->proFeatureUpgradeView(
|
||||
$request,
|
||||
self::FEATURE,
|
||||
'Branches',
|
||||
'Edit branch details with Frontdesk Pro.',
|
||||
)) {
|
||||
return $upgrade;
|
||||
}
|
||||
|
||||
return view('frontdesk.admin.branches.edit', compact('branch'));
|
||||
}
|
||||
|
||||
@@ -83,6 +124,10 @@ class BranchController extends Controller
|
||||
$this->authorizeAbility($request, 'admin.branches.manage');
|
||||
$this->authorizeOwner($request, $branch);
|
||||
|
||||
if ($deny = $this->denyWithoutFeature($request, self::FEATURE, self::UPGRADE_MESSAGE)) {
|
||||
return $deny;
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'code' => ['nullable', 'string', 'max:50'],
|
||||
@@ -93,7 +138,7 @@ class BranchController extends Controller
|
||||
|
||||
$activating = $request->boolean('is_active') && ! $branch->is_active;
|
||||
if ($activating) {
|
||||
$plans = app(\App\Services\Frontdesk\PlanService::class);
|
||||
$plans = app(PlanService::class);
|
||||
$organization = $this->organization($request);
|
||||
if (! $plans->canActivateBranch($organization)) {
|
||||
return back()->withInput()->with('error', $plans->branchLimitMessage($organization));
|
||||
|
||||
Reference in New Issue
Block a user