Add Geographic Models: Province, Location, and Address (#194)
Commit: 8d3f7e24647b2e9dfec243a4f0be371de273e750
Date: 2025-07-06 10:00:28 +0000
Author: PascalHavelange
Commit Message
Add Geographic Models: Province, Location, and Address (#194)
* feat: add geographic models Province, Location, and Address with internationalization
- Add Province model with UUID primary key, country relationship, and multi-language support
- Add Location model with UUID primary key, country/province relationships, and multi-language support
- Add Address model with UUID primary key, country relationship, and multi-language support
- Create ProvinceLanguage, LocationLanguage, and AddressLanguage pivot models for internationalization
- Implement six new migrations with proper foreign key constraints and indexing
- Add API resources for Province, Location, and Address with language data inclusion
- Create full CRUD controllers for all three models with validation and error handling
- Build factories and seeders for all models ensuring proper relationship generation
- Register new seeders in DatabaseSeeder for database population
- Add comprehensive API routes for all three models following RESTful conventions
- Implement 120+ new tests (unit and feature) ensuring complete functionality coverage
- Update documentation with new models, API endpoints, and relationship diagrams
API Endpoints Added:
Province: GET/POST/PUT/DELETE /api/provinces
Location: GET/POST/PUT/DELETE /api/locations
Address: GET/POST/PUT/DELETE /api/addresses
Key Features:
- Geographic hierarchy: Country → Province → Location, with Address linked to Country
- Full internationalization support via pivot tables
- UUID primary keys for scalability and security
- Required country relationships for all models
- Consistent API patterns following Contact model structure
- Comprehensive validation and error handling
- backward_compatibility and internal_name fields for data migration
- Complete test coverage including anonymous access, CRUD operations, and relationships
Database Schema:
- provinces: id (UUID), country_id (required), internal_name, timestamps
- locations: id (UUID), country_id (required), province_id (required), internal_name, timestamps
- addresses: id (UUID), country_id (required), internal_name, timestamps
- province_language: province_id + language_id (composite PK), name, description
- location_language: location_id + language_id (composite PK), name, description
- address_language: address_id + language_id (composite PK), address, description
Documentation Updates:
- CHANGELOG.md with detailed feature descriptions
- docs/api-models.md with comprehensive model documentation
- API relationship diagrams and endpoint specifications
- Internationalization pattern documentation
* api.json
---------
Co-authored-by: Pascal HAVELANGE <havelangep@hotmail.com>
Files Changed
- 📝 Modified:
CHANGELOG.md
- ✅ Added:
app/Http/Controllers/AddressController.php
- ✅ Added:
app/Http/Controllers/LocationController.php
- ✅ Added:
app/Http/Controllers/ProvinceController.php
- ✅ Added:
app/Http/Resources/AddressResource.php
- ✅ Added:
app/Http/Resources/LocationResource.php
- ✅ Added:
app/Http/Resources/ProvinceResource.php
- ✅ Added:
app/Models/Address.php
- ✅ Added:
app/Models/AddressLanguage.php
- ✅ Added:
app/Models/Location.php
- ✅ Added:
app/Models/LocationLanguage.php
- ✅ Added:
app/Models/Province.php
- ✅ Added:
app/Models/ProvinceLanguage.php
- ✅ Added:
database/factories/AddressFactory.php
- ✅ Added:
database/factories/LocationFactory.php
- ✅ Added:
database/factories/ProvinceFactory.php
- ✅ Added:
database/migrations/2025_07_06_000001_create_provinces_table.php
- ✅ Added:
database/migrations/2025_07_06_000002_create_locations_table.php
- ✅ Added:
database/migrations/2025_07_06_000003_create_addresses_table.php
- ✅ Added:
database/migrations/2025_07_06_000004_create_province_language_table.php
- ✅ Added:
database/migrations/2025_07_06_000005_create_location_language_table.php
- ✅ Added:
database/migrations/2025_07_06_000006_create_address_language_table.php
- ✅ Added:
database/seeders/AddressSeeder.php
- 📝 Modified:
database/seeders/DatabaseSeeder.php
- ✅ Added:
database/seeders/LocationSeeder.php
- ✅ Added:
database/seeders/ProvinceSeeder.php
- 📝 Modified:
docs/_openapi/api.json
- ✅ Added:
docs/api-models.md
- 📝 Modified:
routes/api.php
- ✅ Added:
tests/Feature/Api/Address/AnonymousTest.php
- ✅ Added:
tests/Feature/Api/Address/DestroyTest.php
- ✅ Added:
tests/Feature/Api/Address/IndexTest.php
- ✅ Added:
tests/Feature/Api/Address/ShowTest.php
- ✅ Added:
tests/Feature/Api/Address/StoreTest.php
- ✅ Added:
tests/Feature/Api/Address/UpdateTest.php
- ✅ Added:
tests/Feature/Api/Location/AnonymousTest.php
- ✅ Added:
tests/Feature/Api/Location/DestroyTest.php
- ✅ Added:
tests/Feature/Api/Location/IndexTest.php
- ✅ Added:
tests/Feature/Api/Location/ShowTest.php
- ✅ Added:
tests/Feature/Api/Location/StoreTest.php
- ✅ Added:
tests/Feature/Api/Location/UpdateTest.php
- ✅ Added:
tests/Feature/Api/Province/AnonymousTest.php
- ✅ Added:
tests/Feature/Api/Province/DestroyTest.php
- ✅ Added:
tests/Feature/Api/Province/IndexTest.php
- ✅ Added:
tests/Feature/Api/Province/ShowTest.php
- ✅ Added:
tests/Feature/Api/Province/StoreTest.php
- ✅ Added:
tests/Feature/Api/Province/UpdateTest.php
- ✅ Added:
tests/Unit/Address/FactoryTest.php
- ✅ Added:
tests/Unit/Location/FactoryTest.php
- ✅ Added:
tests/Unit/Province/FactoryTest.php
Links
This documentation was automatically generated from Git commit data.