# Module 2 — Fleet Management

Admin CRUD for ambulance types, ambulances, and equipment, in Bootstrap 5
(matching the spec's stated stack — not Breeze's default Tailwind scaffolding).

## Files in this package

```
app/Http/Controllers/Admin/AmbulanceTypeController.php
app/Http/Controllers/Admin/AmbulanceController.php
routes/admin.php
resources/views/layouts/admin.blade.php
resources/views/admin/ambulance-types/{index,create,edit,_form}.blade.php
resources/views/admin/ambulances/{index,create,edit,_form}.blade.php
```

## Setup steps

**1. Copy files** into the matching folders in your project (created in Module 1).

**2. Include the admin routes.** Open `routes/web.php` and add near the bottom:

```php
require __DIR__.'/admin.php';
```

**3. Make sure your admin user actually has the role.** The Module 1 seeder
already assigns `admin` to `admin@patchambulance.co.ke` — log in with that
account to test.

**4. Visit the fleet screens:**

```
/admin/ambulance-types   → add your ambulance types + base pricing first
/admin/ambulances        → then add real vehicles against those types
```

## What this module does

- **Ambulance Types** — name, description, base fare, per-km rate. This is
  the fallback rate used by the fare engine (Module 3) whenever a booking's
  pickup point doesn't fall inside a specific pricing zone.
- **Ambulances** — registration, fleet number, type, make/model/year, status
  (available/busy/maintenance/offline — shown as a color-coded dropdown you
  can change right from the list), and compliance dates (insurance/inspection
  expiry) with an automatic "expired" flag on the list view.
- **Equipment** — a simple add/remove list per ambulance (defibrillator,
  oxygen, stretcher, etc.) with a condition flag, saved alongside the vehicle.
- **Guardrails already built in:** you can't delete an ambulance type that
  still has vehicles assigned to it, and you can't delete an ambulance that
  has a driver or booking history — the system pushes you toward marking it
  "offline" instead, so historical records never break.

## What I deliberately left out of this module

- Driver assignment UI — that's Module 1's `drivers` table already supports
  `assigned_ambulance_id`, but the actual admin screen for creating/assigning
  drivers fits more naturally as part of **User Management** UI, which we
  haven't built screens for yet (Module 1 only did the schema/models/seeder
  for it). Say if you want that built next instead of Module 3.
- A live fleet map — that's explicitly Module 4 (Dispatch), since it needs
  the polling endpoint we designed for shared hosting.

## Next up

Per our build sequence, **Module 3: Booking + Fare/Zone Engine** is next —
the customer-facing booking form, the haversine zone lookup, and the fare
calculation service class. Say the word when ready.
