# Routes

## Public Routes

### `routes/web.php`

```php
<?php

use App\Livewire\Public\StationSearch;
use Illuminate\Support\Facades\Route;

Route::view('/', 'homepage')->name('home');

Route::get('/stations', StationSearch::class)->name('stations.search');

Route::middleware(['auth', 'verified'])->group(function () {
    Route::view('dashboard', 'dashboard')->name('dashboard');
});

require __DIR__.'/settings.php';
```

---

## Settings Routes

### `routes/settings.php`

```php
<?php

use Illuminate\Support\Facades\Route;
use Laravel\Fortify\Features;

Route::middleware(['auth'])->group(function () {
    Route::redirect('settings', 'settings/profile');

    Route::livewire('settings/profile', 'pages::settings.profile')->name('profile.edit');
});

Route::middleware(['auth', 'verified'])->group(function () {
    Route::livewire('settings/appearance', 'pages::settings.appearance')->name('appearance.edit');

    Route::livewire('settings/security', 'pages::settings.security')
        ->middleware(
            when(
                Features::canManageTwoFactorAuthentication()
                    && Features::optionEnabled(Features::twoFactorAuthentication(), 'confirmPassword'),
                ['password.confirm'],
                [],
            ),
        )
        ->name('security.edit');
});
```

**Note:** Auth routes (login, register, password reset, etc.) are provided by Laravel Fortify. See `config/fortify.php` for route definitions.

---

## Route Summary Table

| Method | Path | Name | Component/View | Middleware | Purpose |
|--------|------|------|---|---|---|
| GET | `/` | `home` | `welcome` view | public | Landing page |
| GET | `/stations` | `stations.search` | `StationSearch` Livewire | public | Fuel station search page |
| GET | `/dashboard` | `dashboard` | `dashboard` view | `auth`, `verified` | Authenticated user dashboard |
| GET/POST | `/login` | `login` | Fortify auth | public | User login |
| GET/POST | `/register` | `register` | Fortify auth | public | User registration |
| POST | `/logout` | `logout` | Fortify action | `auth` | Logout action |
| GET/POST | `/forgot-password` | `password.request` | Fortify auth | public | Password reset request |
| GET/POST | `/reset-password/{token}` | `password.reset` | Fortify auth | public | Password reset form |
| GET/POST | `/confirm-password` | `password.confirm` | Fortify auth | `auth` | Confirm password (before sensitive actions) |
| GET/POST | `/verify-email` | `verification.notice` | Fortify auth | `auth` | Email verification |
| GET | `/verify-email/{id}/{hash}` | `verification.verify` | Fortify action | `auth`, `signed` | Verify email action |
| GET/POST | `/two-factor-challenge` | `two-factor.login` | Fortify auth | `guest` | Two-factor challenge |
| GET | `/settings` | (redirect) | → `settings.profile` | `auth` | Redirect to profile |
| GET | `/settings/profile` | `profile.edit` | Livewire `pages::settings.profile` | `auth` | Edit user profile |
| GET | `/settings/appearance` | `appearance.edit` | Livewire `pages::settings.appearance` | `auth`, `verified` | Edit appearance preferences |
| GET | `/settings/security` | `security.edit` | Livewire `pages::settings.security` | `auth`, `verified`, (optional) `password.confirm` | Edit security settings |

---

## Route Grouping

### Public Routes
- Landing page (`/`)
- Station search (`/stations`)
- Fortify auth routes (login, register, password reset, etc.)

### Authenticated Routes
- Dashboard (`/dashboard`)
- Settings pages (`/settings/*`)

### Settings Routes (Special Handling)
- Profile editing: `auth` only
- Appearance: `auth`, `verified`
- Security: `auth`, `verified`, optional password confirmation

---

## Livewire Component Routes

| Route | Livewire Component | View | Purpose |
|-------|---|---|---|
| `/stations` | `App\Livewire\Public\StationSearch` | `livewire.public.station-search` | Interactive fuel station search with map |
| `/settings/profile` | `pages::settings.profile` | `pages.settings.profile` | User profile management |
| `/settings/appearance` | `pages::settings.appearance` | `pages.settings.appearance` | Theme/appearance preferences |
| `/settings/security` | `pages::settings.security` | `pages.settings.security` | Security and 2FA settings |

---

## Notes

- **Fortify**: The application uses Laravel Fortify for authentication scaffolding. Auth routes are auto-registered by Fortify package.
- **Livewire Routes**: Routes using `Route::livewire()` expect corresponding Livewire components in `app/Livewire/`.
- **Middleware Chain**: Routes are protected with `auth` and/or `verified` middleware as appropriate.
- **Settings Redirect**: Accessing `/settings` redirects to `/settings/profile` (first settings tab).

