# Sprint G004, G005, & G006 — Walkthrough

## Sprint G006 — Guest & Invitation Engine

The **Guest & Invitation Engine** extends the workspace and public invitation modules to support personalized guest invitations, salutation prefixes, clipboard sharing, and public routes.

---

## Database Schema Extensions

Added a nullable `honorific` VARCHAR column to the `guests` table to store titles (e.g. Mr., Mrs., Family of):
- Migration script: [G006_guest_engine.sql](file:///c:/xampp/htdocs/inveetaire/database/migrations/G006_guest_engine.sql)
- Query ran on database:
  ```sql
  ALTER TABLE `guests` ADD COLUMN IF NOT EXISTS `honorific` VARCHAR(50) NULL DEFAULT NULL AFTER `full_name` COMMENT 'Guest title/salutation (Mr., Mrs., Family of, etc.)';
  ```

---

## Files Created & Modified

### Modified Files
- [routes.php (PublicInvitation)](file:///c:/xampp/htdocs/inveetaire/app/modules/PublicInvitation/routes.php): Registered the new route pattern `/i/{workspace_slug}/{guest_token}` for personalized URLs, preserving full compatibility with `PublicInvitationController@show`.
- [GuestModel.php](file:///c:/xampp/htdocs/inveetaire/app/modules/Guest/GuestModel.php): Extended `insertGuest()` and `updateGuest()` to persist `honorific` data.
- [GuestValidator.php](file:///c:/xampp/htdocs/inveetaire/app/modules/Guest/GuestValidator.php): Added length validation for the `honorific` field (max 50 characters).
- [GuestController.php](file:///c:/xampp/htdocs/inveetaire/app/modules/Guest/GuestController.php): Updated `store()` and `update()` manual CRUD endpoints to extract and map `honorific`.
- [GuestService.php](file:///c:/xampp/htdocs/inveetaire/app/modules/Guest/GuestService.php): Extended Excel/CSV importer to search for columns matching `prefix`, `honorific`, `gelar`, or `title` to automatically batch import prefixes.
- [create.php (view)](file:///c:/xampp/htdocs/inveetaire/app/views/guest/create.php) & [edit.php (view)](file:///c:/xampp/htdocs/inveetaire/app/views/guest/edit.php): Integrated a new text input for "Honorific / Prefix (Optional)".
- [list.php (view)](file:///c:/xampp/htdocs/inveetaire/app/views/guest/list.php):
  - Prepend `honorific` cleanly to the guest's name if set.
  - Added a **Copy Link** button using Alpine.js and browser clipboard APIs, with a custom, premium bottom toast message.
  - Added a **Preview** link that opens the guest's personalized public invitation in a new tab.

---

## Routing & URL Structure

Personalized public invitations can now be loaded using either structure:
1. **Existing Structure**: `{APP_URL}/{workspace_slug}/i/{guest_token}`
2. **New Structured Path**: `{APP_URL}/i/{workspace_slug}/{guest_token}`

Both routes map to the same thin controller method under the hood, ensuring full backwards compatibility.

---

## Validation & Testing Results

- ✅ `PublicInvitation/routes.php` — No syntax errors
- ✅ `GuestModel.php` — No syntax errors
- ✅ `GuestValidator.php` — No syntax errors
- ✅ `GuestController.php` — No syntax errors
- ✅ `GuestService.php` — No syntax errors
- ✅ `list.php`, `create.php`, `edit.php` views — No syntax errors
- ✅ MariaDB schema updated with `honorific` column
