sadegh19b / laravel-iran-cities
A Laravel package for Iran provinces and cities seeder and models
v1.0.0
2025-06-01 11:42 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
README
A Laravel package for Iran provinces and cities seeder and models.
Supports Laravel 8 to 12.
Installation
You can install the package via composer:
composer require sadegh19b/laravel-iran-cities
Quick Start
- Generate models, migrations, and seeder:
php artisan iran-cities:generate --all
- Run migrations:
php artisan migrate
- Run the seeder:
php artisan db:seed --class="Database\Seeders\IranProvincesAndCitiesSeeder"
- Use the models:
use App\Models\Province; use App\Models\City; // Get all provinces $provinces = Province::all(); // Get cities of a province $province = Province::find(1); $cities = $province->cities;
Generate Stubs
Generate All
To generate models, migrations, and seeder:
php artisan iran-cities:generate --all
Generate Specific
You can also generate specific files:
php artisan iran-cities:generate --models php artisan iran-cities:generate --migrations php artisan iran-cities:generate --seeder
Usage
Get All Provinces or Cities
use App\Models\Province; $provinces = Province::all(); $cities = City::all();
Get Cities of a Province
use App\Models\Province; $province = Province::find(1); $cities = $province->cities;
Get Province of a City
use App\Models\City; $city = City::find(1); $province = $city->province;
License
The MIT License (MIT). Please see License File for more information.