# Incremental Implementation Steps

Each step is self-contained, easy to review, and keeps the existing app working at every checkpoint.

---

## Step 1: Database Migrations Only *(Zero behavior change)*
- Create the migration to:
  - Make `users.email` nullable.
  - Add `is_training_member` (boolean, default `true` so all existing rows stay training members) and `payer_id` to `users`.
  - Create the `user_guardians` pivot table (`user_id`, `guardian_id`, `relationship`, `can_manage`).
- Run `php artisan migrate` against the dev database and confirm `php artisan test` behaves identically.

## Step 2: Model Relationships & Helper Methods
- Add the relationships and helpers to `app/Models/User.php`:
  - `payer()`, `payingFor()`, `guardians()`, `dependants()`
  - `effectivePayer()`
  - `scopeTrainingMembers()`
- Write a feature test covering `effectivePayer()` and `trainingMembers()` across scenarios (child, self-paying teen, husband & wife).

## Step 3: Guard Existing Queries (`trainingMembers()`)
- Update `DashboardController`, `MemberController`, `CheckInController`, `SessionController`, `EngagementController`, and `ReportController` to use `trainingMembers()` where students are listed or counted.
- Ensures non-training `guardian` accounts never pollute attendance, kiosk check-in, rank charts, engagement, or active member counts.

## Step 4: Optional Email on Member Create / Edit
- Update validation in `MemberController` (`store` & `update`) so `email` is optional for training members (while still required for `guardian` / `club_manager` / `admin` accounts).
- Allow clearing fake emails on existing children and saving without error.

## Step 5: "Family & Billing" Panel on `/members/{id}/edit`
- Add the UI on `/members/{id}/edit` (Contact Details) to:
  - Choose who pays (`payer_id`: self or another user).
  - Link/unlink existing guardians or partners (`user_guardians`).
  - Use the **"Create New Parent/Guardian"** modal (pre-filled from emergency contact & address) to create a `guardian` and link them in one click.
- Test-drive on copied production member records in dev before moving on.

---

## Later (Once Steps 1–5 Are Solid)
- **Step 6:** Bulk family-linking / fake-email cleanup helper.
- **Step 7:** Self-service portal (`layouts.portal`, invites, `MemberPolicy`, dependant management).
- **Step 8:** Stripe `invoices`, `/pay/{token}`, webhook handler, and renewal/grading emails.

