# Phase 8: Data Seeder

## Objective
Create a comprehensive data seeder that generates a realistic restaurant dataset for sandbox testing. Includes restaurants, tables, menu categories, menu items with photos, daily menus, reservations, orders, and invoices.

---

## Tasks

### 8.1 RestaurantSeeder

**File:** `database/seeders/RestaurantSeeder.php`

Creates **2 restaurants** attached to existing seeded places:

#### Restaurant 1: "Le Jardin Méditerranéen" (Mediterranean)
- **Place:** First seeded place (Paris)
- **Cuisine:** Mediterranean / French
- **Max covers:** 80
- **Service periods:** Lunch (12:00–14:30), Dinner (19:00–22:30)
- **Reservation duration:** 90 minutes
- **Auto-confirm:** true
- **Accepts pre-orders:** true

#### Restaurant 2: "Sakura Lounge" (Asian Fusion)
- **Place:** Second seeded place (Strasbourg)
- **Cuisine:** Asian Fusion
- **Max covers:** 50
- **Service periods:** Brunch (10:00–14:00), Dinner (18:30–22:00)
- **Reservation duration:** 120 minutes
- **Auto-confirm:** false
- **Accepts pre-orders:** true

---

### 8.2 Tables Seeder

#### Le Jardin Méditerranéen (20 tables)

| Number | Label | Seats | Zone |
|---|---|---|---|
| 1 | Fenêtre jardin | 2 | indoor |
| 2 | Fenêtre rue | 2 | indoor |
| 3 | Pilier central | 4 | indoor |
| 4 | Coin cheminée | 4 | indoor |
| 5 | Grande table | 6 | indoor |
| 6 | Table ronde | 8 | indoor |
| 7 | — | 2 | terrace |
| 8 | — | 2 | terrace |
| 9 | Parasol | 4 | terrace |
| 10 | Parasol | 4 | terrace |
| 11 | Coin jardin | 6 | terrace |
| 12 | — | 2 | bar |
| 13 | — | 2 | bar |
| 14 | — | 2 | bar |
| 15 | Comptoir | 4 | bar |
| 16 | Suite privée A | 6 | private |
| 17 | Suite privée B | 8 | private |
| 18 | Salon VIP | 10 | vip |
| 19 | — | 2 | outdoor |
| 20 | — | 4 | outdoor |

#### Sakura Lounge (15 tables)

| Number | Label | Seats | Zone |
|---|---|---|---|
| 1–4 | — | 2 | indoor |
| 5–7 | — | 4 | indoor |
| 8 | Table communale | 8 | indoor |
| 9–10 | — | 2 | bar |
| 11 | Comptoir sushi | 4 | bar |
| 12–13 | — | 4 | terrace |
| 14 | Tatami room | 6 | private |
| 15 | VIP tatami | 8 | vip |

---

### 8.3 Menu Categories Seeder

#### Le Jardin Méditerranéen

**Food categories:**
- Entrées (children: Salades, Soupes, Tapas)
- Plats (children: Viandes, Poissons, Pâtes, Végétarien)
- Desserts
- Fromages

**Drink categories:**
- Vins (children: Rouges, Blancs, Rosés)
- Cocktails
- Boissons chaudes (children: Cafés, Thés, Infusions)
- Boissons fraîches (children: Jus, Sodas, Eaux)
- Bières

#### Sakura Lounge

**Food categories:**
- Starters (children: Sushi, Sashimi, Gyoza, Edamame)
- Mains (children: Ramen, Wok, Curry, Grillades)
- Desserts
- Sides

**Drink categories:**
- Sake & Spirits
- Cocktails (children: Signature, Classiques)
- Thés (children: Matcha, Sencha, Oolong)
- Boissons fraîches
- Bières

---

### 8.4 Menu Items Seeder (with photos)

#### Le Jardin Méditerranéen (~40 items)

**Photos:** Use Unsplash/Pexels URLs downloaded to storage. Each item gets a realistic food photo.

| Item | Category | Price (EUR) | Member Price | Allergens | Dietary | Calories | Prep (min) |
|---|---|---|---|---|---|---|---|
| Salade Niçoise | Salades | 14.50 | 12.00 | fish, eggs | — | 320 | 10 |
| Soupe de Poissons | Soupes | 12.00 | 10.00 | fish, crustaceans, gluten | — | 280 | 15 |
| Mezze Méditerranéen | Tapas | 16.00 | 14.00 | sesame, dairy, gluten | vegetarian | 450 | 12 |
| Hummus & Pita | Tapas | 9.50 | 8.00 | sesame, gluten | vegan | 350 | 5 |
| Filet de Boeuf | Viandes | 32.00 | 28.00 | — | — | 580 | 25 |
| Côte d'Agneau | Viandes | 28.00 | 24.00 | — | — | 520 | 20 |
| Daurade Grillée | Poissons | 26.00 | 22.00 | fish | gluten_free | 380 | 18 |
| Risotto aux Cèpes | Végétarien | 22.00 | 19.00 | dairy | vegetarian | 480 | 20 |
| Pennes à la Truffe | Pâtes | 24.00 | 21.00 | gluten, dairy | vegetarian | 520 | 15 |
| Tiramisu Maison | Desserts | 10.00 | 8.50 | eggs, dairy, gluten | vegetarian | 380 | 5 |
| Panna Cotta | Desserts | 9.00 | 7.50 | dairy | vegetarian, gluten_free | 310 | 5 |
| Crème Brûlée | Desserts | 10.00 | 8.50 | eggs, dairy | vegetarian, gluten_free | 340 | 5 |
| Assiette de Fromages | Fromages | 14.00 | 12.00 | dairy, nuts | vegetarian | 450 | 5 |
| Bordeaux Rouge (verre) | Rouges | 8.00 | 7.00 | sulphites | vegan | 125 | 2 |
| Côtes de Provence Rosé | Rosés | 7.50 | 6.50 | sulphites | vegan | 120 | 2 |
| Mojito | Cocktails | 12.00 | 10.00 | — | vegan | 180 | 5 |
| Espresso | Cafés | 3.00 | 2.50 | — | vegan | 5 | 3 |
| Thé Vert Menthe | Thés | 4.50 | 3.50 | — | vegan | 5 | 3 |
| Limonade Maison | Jus | 5.50 | 4.50 | — | vegan | 120 | 3 |
| Perrier 75cl | Eaux | 5.00 | 4.00 | — | vegan | 0 | 1 |

*(Continue to ~40 items with similar variety)*

#### Sakura Lounge (~35 items)

| Item | Category | Price (EUR) | Member Price | Allergens | Dietary | Calories | Prep (min) |
|---|---|---|---|---|---|---|---|
| Assortiment Sushi (12p) | Sushi | 22.00 | 19.00 | fish, soybeans, sesame | — | 420 | 15 |
| Sashimi Saumon (8p) | Sashimi | 18.00 | 15.50 | fish | gluten_free | 280 | 10 |
| Gyoza Poulet (6p) | Gyoza | 10.00 | 8.50 | gluten, soybeans, sesame | — | 320 | 12 |
| Edamame | Edamame | 6.00 | 5.00 | soybeans | vegan | 180 | 5 |
| Tonkotsu Ramen | Ramen | 16.00 | 14.00 | gluten, soybeans, eggs | — | 650 | 18 |
| Pad Thaï Crevettes | Wok | 17.00 | 15.00 | crustaceans, peanuts, soybeans | — | 520 | 12 |
| Curry Vert Légumes | Curry | 15.00 | 13.00 | soybeans | vegan | 380 | 15 |
| Boeuf Teriyaki | Grillades | 24.00 | 21.00 | soybeans, sesame | — | 480 | 20 |
| Mochi Assorti (4p) | Desserts | 8.00 | 7.00 | dairy, nuts | vegetarian | 240 | 5 |
| Matcha Latte | Matcha | 5.50 | 4.50 | dairy | vegetarian | 120 | 5 |
| Sake Junmai (carafe) | Sake & Spirits | 14.00 | 12.00 | — | vegan | 200 | 2 |
| Tokyo Mule | Signature | 13.00 | 11.00 | — | vegan | 160 | 5 |

*(Continue to ~35 items)*

---

### 8.5 Daily Menus Seeder

Create menus for the **next 7 days** for each restaurant:

#### Le Jardin Méditerranéen
- **"Menu Déjeuner"** (lunch, each day):
  - Entrée section: 3-4 items
  - Plat section: 3-4 items
  - Dessert section: 2-3 items
- **"Carte du Soir"** (dinner, each day):
  - Full à la carte, all food items
- **"Formule Midi"** (lunch, weekdays only):
  - Entrée + Plat OR Plat + Dessert — 3 items per section, with override prices (cheaper)

#### Sakura Lounge
- **"Brunch Menu"** (brunch, weekends only):
  - Special brunch items
- **"Omakase du Chef"** (dinner, each day):
  - Curated 5-section menu
- **"À la Carte"** (dinner, each day):
  - Full menu

---

### 8.6 Reservations Seeder

Create **30 reservations** spread across the next 7 days for each restaurant:

Mix of statuses:
- 40% CONFIRMED (future)
- 20% PENDING (future)
- 15% COMPLETED (past days)
- 10% SEATED (today)
- 10% NO_SHOW (past)
- 5% CANCELLED (past/future)

Varying party sizes: 1–8 people
Tables assigned for CONFIRMED/SEATED/COMPLETED
Special requests on ~30% of reservations

Use existing seeded customers as reservation users.

---

### 8.7 Orders Seeder

Create **20 PAID orders** for each restaurant over the past 7 days:

- Each order has 2-5 OrderItems pointing to RestaurantMenuItems
- Payment providers mixed: 40% Stripe, 30% Cash, 20% POS, 10% Wallet
- Tips on ~60% of orders (amounts between 2.00–15.00 EUR)
- Restaurant tables assigned
- Invoices generated for each paid order

This gives dashboard endpoints real data to display.

---

### 8.8 Restaurant Manager Employee Seeder

Create **2 restaurant manager employees**, one per restaurant:

- **Employee 1:** "Jean-Pierre Martin" — restaurant_manager role, attached to Place 1 (Paris)
- **Employee 2:** "Yuki Tanaka" — restaurant_manager role, attached to Place 2 (Strasbourg)

Each with:
- Active user account
- Sanctum token for API testing
- Attached to place via `employee_place` pivot

---

### 8.9 Photo Assets

**Directory:** `database/seeders/assets/restaurant/`

Download and store seed photos:

| Type | Count | Source | Naming |
|---|---|---|---|
| Restaurant covers | 2 | Unsplash restaurant interiors | `restaurant_1.jpg`, `restaurant_2.jpg` |
| Menu item photos | ~75 | Unsplash/Pexels food photos | `{slug}.jpg` (e.g., `filet-de-boeuf.jpg`) |
| Category icons | ~15 | Simple food category icons | `cat_{slug}.png` |

Photos attached via Spatie MediaLibrary during seeding using `addMedia()->toMediaCollection()`.

**Alternative:** If downloading photos is impractical, use `addMediaFromUrl()` with stable Unsplash URLs during seeding, or generate placeholder images with a service.

---

### 8.10 Register in DatabaseSeeder

**File:** `database/seeders/DatabaseSeeder.php`

Add `RestaurantSeeder` to the seeder chain, after `PlaceSeeder` and `ClassicSeeder` (depends on places and users existing).

---

## Seeder Execution

```bash
# Run only restaurant seeder
php artisan db:seed --class=RestaurantSeeder

# Run full seed (includes restaurant)
php artisan db:seed
```

---

## Tests

**File:** `tests/Feature/Seeders/RestaurantSeederTest.php`

- [ ] Seeder runs without errors
- [ ] 2 restaurants created with correct places
- [ ] Tables created with correct counts and zones
- [ ] Menu categories with hierarchy created
- [ ] Menu items with allergens and images created
- [ ] Daily menus with sections created for 7 days
- [ ] Reservations created with mixed statuses
- [ ] Orders created with items and invoices
- [ ] Restaurant manager employees created with correct role
- [ ] Photos attached to menu items
- [ ] Seeder is idempotent (can run twice without duplicates)

---

## Files Created/Modified

| Action | File |
|---|---|
| Create | `database/seeders/RestaurantSeeder.php` |
| Create | `database/seeders/assets/restaurant/` (photo directory) |
| Modify | `database/seeders/DatabaseSeeder.php` — add RestaurantSeeder |

---

## Acceptance Criteria

- [ ] `php artisan db:seed --class=RestaurantSeeder` runs cleanly
- [ ] 2 distinct restaurants with different cuisines and configurations
- [ ] 35 tables total with proper zones and capacities
- [ ] ~75 menu items with photos, allergens, dietary labels, and 3-tier pricing
- [ ] Daily menus for 7 days with sections and curated items
- [ ] 60 reservations with realistic status distribution
- [ ] 40 paid orders with items, tips, and invoices
- [ ] 2 restaurant manager employees with API tokens
- [ ] Dashboard endpoints return meaningful data from seeded data
- [ ] Photos display correctly in both Filament and API responses
- [ ] Seeder can run on fresh database after standard seeders
