# Landing Page

**Portal:** Manage · **Route:** `manage.settings.landing.*` (`/manage/settings/landing`) · **Nav:** Setting → **Landing Page**, on both Setting hubs (Operations `SettingTabs`, and the AI Appointment System's `AeSettingTabs`) · **Who:** Super Admin

## What it does

Chooses where an admin lands after signing in at `/manage/login` on **this install**: the Hub (the suite chooser, the default) or straight into one suite — AI Appointment System dashboard, New Project Suite, or Subsale Suite. Built 2026-11-06 for sites that only use one suite: VF works only in the AI Appointment System, so its admins should land on `/manage/appointment-engine/dashboard` instead of choosing a suite every time.

The same page can also **turn the Hub off** on the install (2026-11-15, Lee Jie for VF: Wai Kit found VF's admins could still reach the Hub, which confused them). The Hub's address then opens the chosen landing, and the "Back to Hub" links disappear from the manage sidebar and the portal sidebar.

Both are one value per install (the `settings` table), not per user and not per agency.

## How it works

- **Stored** as `settings.manage.landing` (`Setting::MANAGE_LANDING`), holding a key of `Setting::MANAGE_LANDINGS`. Choosing the Hub deletes the row (`SettingRepository::forget`), so "unset" and "Hub" are the same state.
- **The choices** are the `Setting::MANAGE_LANDINGS` constant, one entry per landing: `name`, `description`, `path`, the `feature` flag its routes are registered under, and the `permission` those routes ask for. A new suite is one more entry there.
- **Read at sign-in** by `App\Http\Controllers\Concerns\ResolvesPortalHome::homeFor()`, the one place the admin sign-ins resolve a landing: the password login, the email / phone code login (`PasswordlessLoginController`), the already-signed-in bounce on `/manage/login`, and `EnsurePortalEnabled`. (`MagicLoginController` is a customer link and always lands on the investor portal.) For the admin door it returns the chosen path **only when** the suite's feature flag is on **and** the admin holds its permission. Otherwise it returns the Hub. A choice can therefore never sign anyone in to a 403 or a 404.
- **Order of precedence** at the admin door: a link the admin was sent to before signing in (`redirect()->intended`) wins, then a CEO-team member's own list, then this setting, then the Hub.
- **Not affected while the Hub is on:** `/manage` (redirects to the Hub), the customer door `/login` (always the investor portal), and the Hub itself, which stays one click away from every suite (the sidebar's back link).
- **Turning the Hub off** is stored as `settings.manage.hub_off` (`Setting::MANAGE_HUB_OFF`, `"1"`; switching it back on deletes the row). It needs a suite landing: `UpdateRequest` refuses Hub-off with the Hub as the landing, and the page unticks the box when the Hub is picked. Both values are saved in one transaction (`SettingRepository::putMany`, where `null` deletes a row).
- **What Hub-off does.** `Manage\DashboardController@index` asks `ResolvesPortalHome::hubRedirectFor()` and redirects to the chosen landing. The rule lives at the Hub's own route, so everything that still names the Hub follows it: `/manage`, the sign-in fallback in `homeFor()`, `EnsurePortalEnabled`'s staff redirect, an old tab, a bookmark. The shared prop `features.hub` (`HandleInertiaRequests`) gives the same answer, and `ManageLayout` / `AppLayout` hide "Back to Hub" when it is `false`.
- **Never an error page.** `hubRedirectFor()` returns the landing only when this admin could open it (`chosenLandingFor()`: the suite's feature flag is on and the admin holds its permission). Otherwise the Hub renders as before and their "Back to Hub" link stays. So a role without the suite, or a suite later switched off in `.env`, gets the Hub instead of a 403 or a 404.
- **The page** lists every choice. A suite whose feature flag is off on this install is shown but disabled. Super-admin only: the route group carries `super-admin` middleware, and `UpdateRequest::authorize()` checks again.
- **The member portal is a separate switch.** Wai Kit's question covered both the Hub and the user portal. The portal is closed with `FEATURE_PORTAL_ENABLED=false` in the site's `.env` (see `docs/modules_handbook/main/portal-off-switch/readMe.md`), which also hides the sidebar's "Switch to User Portal".

## Related files

**Backend**
- `src/Setting/Setting.php` — `MANAGE_LANDING`, `MANAGE_HUB_OFF`, `MANAGE_LANDING_*`, `MANAGE_LANDINGS`
- `src/Setting/Repositories/SettingRepository.php` — `putMany()` (a `null` value deletes the row)
- `app/Http/Controllers/Concerns/ResolvesPortalHome.php` — `homeFor()` applies the landing; `chosenLandingFor()` and `hubRedirectFor()` decide the Hub-off redirect
- `app/Http/Controllers/Manage/DashboardController.php` — the Hub; redirects when it is off
- `app/Http/Middleware/HandleInertiaRequests.php` — `features.hub`
- `app/Http/Controllers/Manage/Settings/LandingController.php`
- `app/Http/Requests/Manage/Settings/Landing/UpdateRequest.php`

**Frontend**
- `resources/js/Pages/Manage/Settings/Landing.vue` — mounts `AeSettingTabs` when the resolved suite is `appointment`, else `SettingTabs`
- `resources/js/Components/SettingTabs.vue`, `resources/js/Components/AppointmentEngine/AeSettingTabs.vue` — the **Landing Page** tab (`is_super_admin`)
- `resources/js/Layouts/ManageLayout.vue`, `resources/js/Layouts/AppLayout.vue` — "Back to Hub" hidden when `features.hub` is `false`

**Routes** — `routes/web.php`: `GET|PUT manage/settings/landing` (`manage.settings.landing.index` / `.update`)

**Tests** — `tests/Feature/Auth/PortalHomeRedirectTest.php` (`test_the_admin_door_lands_on_the_sites_chosen_suite_when_the_admin_can_open_it`, `test_with_the_hub_off_its_address_opens_the_chosen_suite_but_never_a_403`)

**Migrations** — none (a `settings` row).
