AngolanGeo is a PHP Composer package that simplifies the process of creating and populating models for Provincia (Provinces) and Municipio (Municipalities) with accurate data of provinces and cities in Angola. This package is designed to seamlessly integrate with Laravel projects, providing an easy way to incorporate Angolan geographical information.
You can install the package via composer:
composer require josecaseiro/angolan-geo
After installing, you need to add the following line to the run method in your DatabaseSeeder file:
$this->call([ProvinciaSeeder::class]);
Your DatabaseSeeder under database\seeders should look like this:
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Josecaseiro\AngolanGeo\Seeders\ProvinciaSeeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call([ProvinciaSeeder::class]);
}
}
Finally execute commands to import all data to your database:
php artisan migrate
then
php artisan db:seed
use Josecaseiro\AngolanGeo\Models\Provincia;
use Josecaseiro\AngolanGeo\Models\Municipio;
// Get all Provinces
$provincias = Provincia::all();
// Get a Province by name
$province = Provincia::where('name', 'Luanda')->first();
// Get all Municipios
$municipios = Municipio::all();
// Get Municipios by a Province
$luanda = Provincia::where('name', 'Luanda')->first();
$municipiosLuanda = $luanda->municipios;
// From a Municipio you can get its Province
$municipio = Municipio::first();
$prov = $municipio->provincia;
- Easy Integration: Seamlessly integrate Provincia and Municipio models into your Laravel projects.
- Data Accuracy: Utilize a reliable and regularly updated dataset of Angolan provinces and municipalities.
- Efficient Model Population: Simplify the process of populating your models with pre-existing data.
- Localization Support: The package aligns with Angola's administrative divisions, providing accurate localized data.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.