# Locations

The location catalog provides country, city, region, and currency data used by buildings and the public search.

## Models

| Model | Purpose |
|-------|---------|
| `Country` | Top-level country. |
| `City` | City within a country. |
| `Region` | Region/neighborhood within a city. |
| `Currency` | Currency used by buildings. |

## Relationships

- `Country` has many `City`
- `City` belongs to `Country` and has many `Region`
- `Region` belongs to `City` and has many `Building`
- `Country` belongs to `Currency`
- `Building` belongs to `Region` and `Currency`

## Admin management

Admins can create, update, and delete locations. The admin endpoints are prefixed with `/api/v1/admin/`.

## Public read-only access

Unauthenticated users can list and show countries, cities, regions, and currencies. These endpoints power the public catalog filters.

## Seeding

The `LocationSeeder` seeds the configured countries (default: Libya) from `database/data/locations.json`. To download fresh location data:

```bash
php artisan locations:download
```

This command fetches an external dataset, filters it by `config('locations.seed_countries')`, and writes `database/data/locations.json`.

## Configuration

`config/locations.php` contains:

```php
'seed_countries' => explode(',', env('SEED_COUNTRIES', 'Libya')),
```

Use the `SEED_COUNTRIES` environment variable to control which countries are seeded.
