Laravel World is a complete resource for managing location data in your Laravel applications. This repository provides migrations and seeders for tables related to countries, provinces, cities, districts, villages and postal codes. Using this repository, you can easily integrate geographic data structures into your Laravel projects, enabling efficient and structured management of location information.
Packages provide valuable functionality, yet they introduce a level of dependency. We must incorporate their service providers into our applications and adhere to their documentation, even for tasks we could accomplish independently.
Personally, I've often felt overwhelmed, particularly when tasked with creating tables for countries, states, and cities using Laravel migrations and seeding them. Consequently, I've developed migrations and seeders to streamline this process, drawing inspiration from two widely recognized repositories (credited below).
It is important to note that this is not a stand-alone package, but instead contains migration and seeder files for countries, states, cities, districts and villages. You are free to use standard Laravel relationships and code in your projects as needed.
- Migrations and Seeders for Country, State, City, District, Village, and Postal Codes Tables.
- Comprehensive and accurate data to establish a strong foundation for location management.
- Easily integrable into existing Laravel projects.
- Expandable data structure to meet the specific needs of your project.
- PHP
^8.1
or Above - Laravel 9 or Above
To install Laravel World, follow these steps:
Clone repository and move migrations and seeders into relevant directories.
git clone https://github.com/muhamdaily/laravel-world.git
Register Seeders into database/seeders/DatabaseSeeder.php
by adding these line in run method
public function run(): void
{
// \App\Models\User::factory(10)->create();
// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
$this->call(CountrySeeder::class);
$this->call(StateSeeder::class);
$this->call(CitySeeder::class);
$this->call(DistrictSeeder::class);
$this->call(VillageSeeder::class);
$this->call(PostalCodeSeeder::class);
}
Run Migrations and Seed the Database.
php artisan migrate --seed
If you want to run fresh migrations and seed the database, you can use the following command:
php artisan migrate:fresh --seed
This command will drop all tables and then re-run the migrations, seeding the database with the initial data.
To contribute to Laravel World, follow these steps:
- Fork this repository.
- Create a branch:
git checkout -b <branch_name>
. - Make your changes and commit them:
git commit -m '<commit_message>'
- Push to the original branch:
git push origin <project_name>/<location>
- Create the pull request.
Alternatively see the GitHub documentation on creating a pull request.
Thanks to the following people who have contributed to this project:
If you want to contact me you can reach me at muhammadmauribi@gmail.com.
This Laravel Auth repository is open-source software licensed under the MIT License.