Files
ladill-frontdesk/app/Http/Controllers/Frontdesk/BuildingController.php
T
isaaccladandCursor 9e2d79936c
Deploy Ladill Frontdesk / deploy (push) Failing after 35s
Test / test (push) Failing after 2m45s
Initial Ladill Frontdesk release with deploy pipeline.
Visitor management app with SSO, kiosk, badges, reports, and Gitea CI deploy to frontdesk.ladill.com.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 20:37:15 +00:00

57 lines
1.7 KiB
PHP

<?php
namespace App\Http\Controllers\Frontdesk;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Frontdesk\Concerns\ScopesToAccount;
use App\Models\Branch;
use App\Models\Building;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class BuildingController extends Controller
{
use ScopesToAccount;
public function index(Request $request, Branch $branch): View
{
$this->authorizeAbility($request, 'admin.branches.view');
$this->authorizeOwner($request, $branch);
$buildings = $branch->buildings()->withCount('receptionDesks')->orderBy('name')->get();
return view('frontdesk.admin.buildings.index', compact('branch', 'buildings'));
}
public function store(Request $request, Branch $branch): RedirectResponse
{
$this->authorizeAbility($request, 'admin.branches.manage');
$this->authorizeOwner($request, $branch);
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
'floor_count' => ['nullable', 'string', 'max:20'],
]);
Building::create([
'owner_ref' => $this->ownerRef($request),
'branch_id' => $branch->id,
...$validated,
]);
return back()->with('success', 'Building added.');
}
public function destroy(Request $request, Branch $branch, Building $building): RedirectResponse
{
$this->authorizeAbility($request, 'admin.branches.manage');
$this->authorizeOwner($request, $building);
abort_unless($building->branch_id === $branch->id, 404);
$building->delete();
return back()->with('success', 'Building removed.');
}
}