abdomassoun / algeria-wilayas
This package is designed to help Laravel developers integrate wilayas data into their projects in the easiest way possible. It includes an enum of wilayas and provides the ability to create a table that includes all the data of wilayas with their information (optional to create a table of wilayas).
Requires
- php: >=8.2
Requires (Dev)
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^11.1
README
This package is designed to help Laravel developers integrate wilayas data into their projects in the easiest way possible. It includes an enum of wilayas and provides the ability to create a table that includes all the data of wilayas with their information (optional to create a table of wilayas). It also includes a Wilaya model (class).
Usage
Here are the step-by-step instructions on how to install:
-
Run the following command to install the package:
composer require abdomassoun/algeria-wilayas
This command will add the
Wilaya
class to your project, along with a migration for it. It will also create an enum calledWilayaEnum
which includes various functions to work with the enum. -
(Optional) If you want to create a database seed, run the following command:
php artisan vendor:publish --tag=seeders
This command will publish the seeders for the package, allowing you to seed the wilayas data into your database.
-
You can now use the
Wilaya
class and theWilayaEnum
enum in your Laravel project. Here's an example of how to use the enum:use App\Enums\WilayaEnum; // Get all wilayas $wilayas = WilayaEnum::all(); // Get the name of a wilaya by its code $wilayaName = WilayaEnum::getNameByCode('01'); // Get the code of a wilaya by its name $wilayaCode = WilayaEnum::getCodeByName('Adrar');
Feel free to explore the
Wilaya
class and theWilayaEnum
enum to discover more functions and features.For more information, please refer to the package documentation.
Contributing
We welcome and encourage contributions to further develop this package. We appreciate any help and ideas. Please check the issues to see how you can contribute.
License
This package is licensed under the MIT License (MIT).