# WhatsApp Number Required Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

**Goal:** Make `whatsapp_number` required (non-nullable and validated) for owners, customers, and pending customers across migrations, form requests, controllers, and tests.

**Architecture:** Remove `->nullable()` from the `whatsapp_number` columns in the `owners` and `customers` migrations, change the relevant Form Request rules from `nullable`/`sometimes` to `required`, remove null coalescing fallbacks in controllers, and update all direct `Owner::create` / `Customer::create` calls in tests to supply a WhatsApp number.

**Tech Stack:** Laravel 11, PHP 8.3, Pest/PHPUnit, SQLite/MySQL

---

### Task 1: Update migrations

**Files:**
- Modify: `database/migrations/2026_06_08_101438_create_owners_table.php`
- Modify: `database/migrations/2026_06_08_101658_create_customers_table.php`

- [ ] **Step 1: Remove `->nullable()` from owners migration**

Change:
```php
$table->string('whatsapp_number')->nullable();
```
to:
```php
$table->string('whatsapp_number');
```

- [ ] **Step 2: Remove `->nullable()` from customers migration**

Change:
```php
$table->string('whatsapp_number')->nullable();
```
to:
```php
$table->string('whatsapp_number');
```

---

### Task 2: Update Form Request validation rules

**Files:**
- Modify: `app/Http/Requests/Auth/RegisterOwnerRequest.php`
- Modify: `app/Http/Requests/Auth/RegisterCustomerRequest.php`
- Modify: `app/Http/Requests/PendingCustomerRequest.php`
- Modify: `app/Http/Requests/Customer/UpdateProfileRequest.php`

- [ ] **Step 1: Make `whatsapp_number` required in RegisterOwnerRequest**

Change:
```php
'whatsapp_number' => ['nullable', 'string', 'max:255', new WhatsAppNumber],
```
to:
```php
'whatsapp_number' => ['required', 'string', 'max:255', new WhatsAppNumber],
```

- [ ] **Step 2: Make `whatsapp_number` required in RegisterCustomerRequest**

Apply the same change as Step 1.

- [ ] **Step 3: Make `whatsapp_number` required in PendingCustomerRequest**

Apply the same change as Step 1.

- [ ] **Step 4: Make `whatsapp_number` required in UpdateProfileRequest**

Change:
```php
'whatsapp_number' => ['sometimes', 'nullable', 'string', 'max:255', new WhatsAppNumber],
```
to:
```php
'whatsapp_number' => ['sometimes', 'required', 'string', 'max:255', new WhatsAppNumber],
```

---

### Task 3: Update controllers

**Files:**
- Modify: `app/Http/Controllers/Api/AuthController.php`

- [ ] **Step 1: Remove null fallback when creating owner**

Change:
```php
'whatsapp_number' => $data['whatsapp_number'] ?? null,
```
to:
```php
'whatsapp_number' => $data['whatsapp_number'],
```

- [ ] **Step 2: Remove null fallback when creating customer**

Apply the same change as Step 1.

---

### Task 4: Update tests with direct model creation

**Files:**
- Modify all test files containing `Owner::create` or `Customer::create` that do not already include `whatsapp_number`.

- [ ] **Step 1: Add `whatsapp_number` to owner creations**

For every `Owner::create([...])` call that lacks `whatsapp_number`, add:
```php
'whatsapp_number' => '+12025550100',
```

- [ ] **Step 2: Add `whatsapp_number` to customer creations**

For every `Customer::create([...])` call that lacks `whatsapp_number`, add:
```php
'whatsapp_number' => '+12025550100',
```

---

### Task 5: Verify

- [ ] **Step 1: Refresh migrations**

Run:
```bash
php artisan migrate:fresh
```
Expected: migrations complete without errors.

- [ ] **Step 2: Run full test suite**

Run:
```bash
php artisan test
```
Expected: all tests pass.

---

## Self-Review

1. **Spec coverage:** Migrations, registration requests, pending customer request, profile update request, auth controller, and test data are all covered.
2. **Placeholder scan:** No TBD/TODO placeholders; every step contains concrete code/commands.
3. **Type consistency:** `whatsapp_number` is consistently treated as a required string validated by `WhatsAppNumber`.
