https://github.com/zalanihir/country-state-city-package
Migrate the contry, state & cities in your project with flags
https://github.com/zalanihir/country-state-city-package
Last synced: 2 months ago
JSON representation
Migrate the contry, state & cities in your project with flags
- Host: GitHub
- URL: https://github.com/zalanihir/country-state-city-package
- Owner: ZalaNihir
- Created: 2024-02-04T10:15:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-30T13:59:41.000Z (7 months ago)
- Last Synced: 2025-03-27T04:41:36.930Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 1.06 MB
- Stars: 23
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
## Laravel Country, State, City Seeder Package
Hi, I created a package for country, state & and city seeder. You can install and use it in your laravel project. If you are using this package then you can give it a star this package is free, In the future I Will add the country code & phone initials.
## What is this library?
This is a library called CSC aka Country-State-City Seeders. While developing, I faced the issues so often that where can I get the seeder files? & how can I manage it? Is there a relationship or not?
So I googled & found some seeders files & with that help, I made this library which already has a relationship between their models.
## Why do you need this?
If your project needs the country state & city dropdown & you have no idea about how it works I already made the library for it. Here are some of the points.
- Open Source & Free
- Easy to install
- Easy to modify
- Models have already a relationship
## For Installation
- To install this package you have to install this package using composer.
## Note:
Make sure you do not have any country, state & city models or migrations then remove it other this will create conflicts.
# How to install it?
```bash
composer require zalanihir/country-state-city
```## For Publishers
# For Laravel 10 or Laravel 9
you have to add the bellow line in ```app.php``` in ```providers``` section.
```bash
\Nihir\CountryStateCity\CountryStateCityServiceProvider::class,
```# For Laravel 11
you have to add the bellow line in ```providers.php``` which is In the bootstrap folder.
```bash
\Nihir\CountryStateCity\CountryStateCityServiceProvider::class,
```publishing command
```bash
php artisan vendor:publish --provider="Nihir\CountryStateCity\CountryStateCityServiceProvider"
```The previous command publishes the files in your project.
Now you can simply run the following commands.
```bash
php artisan optimize:clear
php artisan config:cache
```This will clear your caches
```bash
php artisan migrate
```This will migrate the tables into databases.
Now add this line in your ```DataBaseSeeder.php``` file.
```bash
$this->call(CountryStateCityTableSeeder::class);
```Now Simplay runs the following command for the seed of the database.
```bash
php artisan db:seed
```The CountryModel, CityModel & StateModel has already relationships you do not have to worry about relationships & more than that I updated the Country Model, Migration & DataProvider and I added the iso2, iso3, numcode & country phonecode & country Flags as well.
## Country Flags
In order to use the country flages you have to first get the flags by using bellow command.
```bash
php artisan csc:publish-flags
```After the command you will see that in your public folder there is one more folder will be added named flags.So now you have to just use it Here I will give you a basic example of that how to use it you can customize it for sure as per your need.
```bash
use App\Models\Country;$countries = Country::get();
@foreach ($countries as $country)
![]()
@endforeach```
## Friendly Note
if you have any query about this package face some error or need support to update simply mail me [email protected].
I get the all flags from the ```https://flagsapi.com/``` So the which size is 64 This would take alot time to manage it & some of countries's flags I did not get I will be updated soon if you want to update it & contribute in the project you can do it as well this will be vary helpfull for me. Thank you.
# Connect with me
[](https://twitter.com/NihirZala)[](https://www.linkedin.com/in/nihirzala/)
[](https://www.instagram.com/inihirzala/)
[](mailto:[email protected])

## Contributors
Thank you to all the wonderful people who contributed to this project!
Want to contribute? Check out our [Contributing Guidelines](CONTRIBUTING.md).
# Other Project
Check my Admin Panel