Easily add all the 58 Algerian Wilayas and its Dairas to your cool Laravel project (Migrations, Seeders and Models).

Overview

Laravel-Algereography

Laravel-Algereography allows you to add Migrations, Seeders and Models of Algerian Wilayas and Dairas to your existing or new cool Laravel project .

- 58 Wilayas.
- 548 Dairas.
- Support both Arabic and French languages.
- Built in models relationships, so you can for example do: Daira::find(1)->wilaya to get the Wilaya of Daira with the id=1.

Installation

Step 1 - Require the package

composer require thehocinesaad/laravel-algereography

Step 2: Install the package

php artisan algereography:install

This command will do those good stuff for you:

  1. Publish two Models, Wilaya and Daira to app/Models.

  2. Publish two Migrations, create_wilayas_table and create_dairas_table to database/migrations

  3. Publish two Seeders, WilayaSeeder and DairaSeeder to database/seeders

  4. Run the two Migrations (create_wilayas_table and create_dairas_table)
    Note: this operation will automatically overwrite any table with the name of wilayas and dairas

  5. Run the two Seeders (WilayaSeeder and DairaSeeder)

  6. Finally, it prints Done! to make you know that everything is succefully finished then it will print 1 2 3 Viva l'Algérie! just to make you a little bit proud of your country ❤️

Step 3:

There is no step 3, you're done 😉
Check out your database and you will find two new tables, wilayas and dairas.

How can I use the package

As mentioned before, the package publishes two models Wilaya and Daira, use them just like any other model in your project.

Get all Wilayas

Wilaya::all();

Get all Dairas

Daira::all();

Get Dairas of a Wilaya

Wilaya::findOrFail(15)->dairas

Get Wilaya of a Daira

Daira::findOrFail(205)->wilaya;

Note: Don't forget to import the models first:

use App\Models\Wilaya;
use App\Models\Daira;

Helpers

You can also use the package using some Helpers I added that will make your life easier.

Helpers list:

$wilayas     =   wilayas();           // Get all Wilayas in all languages
$ar_wilayas  =   wilayas('ar');       // Get all Wilayas in arabic
$ar_wilayas  =   wilayas('fr');       // Get all Wilayas in french

//

$wilaya      =   wilaya(15);          // Get individuel Wilaya in all languages
$ar_wilaya   =   wilaya(15, 'ar');    // Get individuel Wilaya in arabic
$wilaya      =   wilaya(15, 'fr');    // Get individuel Wilaya in french

//

$dairas      =   dairas();            // Get all Dairas in all languages             
$ar_dairas   =   dairas('ar');        // Get all Dairas in arabic 
$fr_dairas   =   dairas('fr');        // Get all Dairas in french

//

$dairas      =   dairasOf(15);        // Get all Dairas of a Wilaya in all languages
$dairas      =   dairasOf(15, 'ar');  // Get all Dairas of a Wilaya in arabic
$dairas      =   dairasOf(15, 'fr');  // Get all Dairas of a Wilaya in french
When specifying the language, to access the name attribute just do ->name and it will automatically get the name in the correct language, so there is no need to do ->ar_name to get the name in arabic.

Example

$fr_wilaya  =  wilaya(15, 'fr');   // $fr_wilaya->name will be 'Tizi Ouzou' 
$ar_wilaya  =  wilaya(15, 'ar');   // $ar_wilaya->name will be 'تيزي وزو' 

How cool is that!

Contributing

Thank you for considering contributing to Laravel-Algereography project! Feel free to contribute in any way, we welcome every contribution.

License

Laravel-Algereography project is open-sourced software licensed under the MIT license.

You might also like...
This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.

Laravel Verify New Email Laravel supports verifying email addresses out of the box. This package adds support for verifying new email addresses. When

Easily add Laravel Telescope and Horizon to Filament admin panel.

Filament Debugger This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. Installation You can inst

Add variables to the payload of all jobs in a Laravel app
Add variables to the payload of all jobs in a Laravel app

Inject extra info to the payloads of all jobs in a Laravel app This package makes it easy to inject things in every job. Imagine that you want to have

Automatic Laravel model migrations.

Laravel Automatic Migrations Automatic Laravel model migrations. Instead of having to create and manage migration files, this package allows you to sp

Laravel MiGator - Migrations Generator
Laravel MiGator - Migrations Generator

Laravel Migator A package that will allow developers to interactively generate schema migrations for a laravel application. It takes into account the

Add a general-purpose tools page to your Filament project. 🛠
Add a general-purpose tools page to your Filament project. 🛠

Add a general-purpose tools page to your Filament project. Installation You can install the package via Composer: composer require ryangjchandler/fila

Validate PHP database migration files for compliance with best practices. Ensure db migrations are irreversible.
Validate PHP database migration files for compliance with best practices. Ensure db migrations are irreversible.

PHP DB Migration Validator Introduction In modern PHP frameworks such as Symfony and Laravel, migrations usually have up and down methods. In up metho

This package extends Illuminate to provide partitioned table creation in migrations.
This package extends Illuminate to provide partitioned table creation in migrations.

Laravel Partitions for Migrations This package extends Illuminate to provide partitioned table creation in migrations for PostgreSQL. Support for othe

Easily Integrate PingPing APIs in your Laravel Project

PingPing This composer package allows us to easily integrate PingPing APIs in your Laravel project. What is PingPing ? PingPing is the simplest uptime

Releases(v1.3.0)
Owner
Hocine Saad
Hocine Saad
The list of all Algerian provinces and cities according to the official division in different formats: csv, xlsx, php, json, etc.

algeria-cities This repository contains the list of all the administrative provinces and cities in Algeria. The data is up-to-date according to the of

Ramtani Othmane 393 Jan 2, 2023
Declare database migrations and factory definitions inside Laravel models.

Lucid This package allows you to declare database migrations and factory definitions inside of your Laravel models. Running the lucid:migrate command

null 23 Jul 9, 2022
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.

Webdevetc BlogEtc - Complete Laravel Blog Package Quickly add a blog with admin panel to your existing Laravel project. It has everything included (ro

WebDevEtc. 227 Dec 25, 2022
Laravel 2-Step Verification is a package to add 2-Step user authentication to any Laravel project easily.

Laravel 2-Step verification is a package to add 2-Step user authentication to any Laravel project easily. It is configurable and customizable. It uses notifications to send the user an email with a 4-digit verification code. Laravel 2-Step Authentication Verification for Laravel. Can be used in out the box with Laravel's authentication scaffolding or integrated into other projects.

Jeremy Kenedy 204 Dec 23, 2022
A site which you can apply jobs or search for employees with cool functionalities..

About App An App which you can apply jobs or search for employees with cool functionalities. Some Pics of App Click Image to Zoom in Sign In & Up Empl

Fatih Canbolat 1 Jan 7, 2022
This package allows you to easily work with NanoID in your Laravel models.

Laravel Model UUIDs Introduction Huge thanks to Micheal Dyrynda, whose work inspired me to create this package based on laravel-model-nanoid but uses

Parables Boltnoel 3 Jul 27, 2022
Generate trends for your models. Easily generate charts or reports.

Laravel Trend Generate trends for your models. Easily generate charts or reports. Support us Like our work? You can support us by purchasing one of ou

Flowframe 139 Dec 27, 2022
cybercog 996 Dec 28, 2022
This is a Laravel package for msegat. Its goal is to remove the complexity

laravel-msegat package This is a Laravel package for msegat. Its goal is to remove the complexity Laravel Msegat Package This is a package for msegat.

Moemen Gaballah 8 Dec 13, 2022
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.

Laravel-Mediable Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel. Features Filesystem-driven appro

Plank Design 654 Dec 30, 2022