# NGBVD FGM Posting and Alerts Fix

## Issue fixed
Posting to `/dataentry/postfmg` was falling through to the custom 404/error page. While rendering the error page, `resources/views/components/alerts.blade.php` crashed because `$errors` was not available in that rendering context.

## Files included
- `resources/views/components/alerts.blade.php` - safely handles cases where `$errors` is not available.
- `app/Http/Controllers/FgmDataController.php` - handles POST `/dataentry/postfmg` with validation and transaction-safe save.
- `resources/views/dataentry/fgm.blade.php` - fixes the Quarter field name/id and avoids requiring every service row to be filled.
- `database/migrations/2026_06_04_000140_create_fgm_tables_if_missing.php` - creates `fgm_details` and `fgm_services` if they do not exist.
- `patches/routes_web_add_fgm_route.diff` - route line to add to `routes/web.php`.

## Route to add manually if not merged automatically
```php
Route::post('/dataentry/postfmg', [App\Http\Controllers\FgmDataController::class, 'store'])
    ->name('/dataentry/postfmg')
    ->middleware('auth');
```

## Commands
```powershell
composer dump-autoload
php artisan migrate --path=database/migrations/2026_06_04_000140_create_fgm_tables_if_missing.php
php artisan optimize:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
```

## Test
1. Open `/dataentry/fgm`.
2. Enter financial year, quarter, number, district, sub-county, parish, and village.
3. Enter service counts where applicable.
4. Submit.
5. Confirm the page redirects back with a success message and no error.
