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,6 +3,7 @@
|
||||
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\Models\Building;
|
||||
@@ -12,13 +13,27 @@ use Illuminate\View\View;
|
||||
|
||||
class BuildingController 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, Branch $branch): View
|
||||
{
|
||||
$this->authorizeAbility($request, 'admin.branches.view');
|
||||
$this->authorizeOwner($request, $branch);
|
||||
|
||||
if ($upgrade = $this->proFeatureUpgradeView(
|
||||
$request,
|
||||
self::FEATURE,
|
||||
'Branches',
|
||||
'Manage buildings and reception desks with Frontdesk Pro.',
|
||||
)) {
|
||||
return $upgrade;
|
||||
}
|
||||
|
||||
$buildings = $branch->buildings()->withCount('receptionDesks')->orderBy('name')->get();
|
||||
|
||||
return view('frontdesk.admin.buildings.index', compact('branch', 'buildings'));
|
||||
@@ -29,6 +44,10 @@ class BuildingController 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'],
|
||||
'floor_count' => ['nullable', 'string', 'max:20'],
|
||||
@@ -49,6 +68,10 @@ class BuildingController extends Controller
|
||||
$this->authorizeOwner($request, $building);
|
||||
abort_unless($building->branch_id === $branch->id, 404);
|
||||
|
||||
if ($deny = $this->denyWithoutFeature($request, self::FEATURE, self::UPGRADE_MESSAGE)) {
|
||||
return $deny;
|
||||
}
|
||||
|
||||
$building->delete();
|
||||
|
||||
return back()->with('success', 'Building removed.');
|
||||
|
||||
Reference in New Issue
Block a user