josecaseiro/angolan-geo

The angolan-geo Composer package is crafted to streamline the process of building models for Provincia (Provinces) and Municipio (Municipalities) in PHP applications, specifically tailored to the unique geographical structure of Angola. This package is a valuable asset for developers working on proj

1.1.3 2024-06-30 01:18 UTC

This package is auto-updated.

Last update: 2024-09-30 01:57:44 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.

Installation

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

Usage

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;

Features

  • 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.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email jvcaseiro@hotmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.