sadegh19b/laravel-iran-cities

A Laravel package for Iran provinces and cities seeder and models

v1.0.0 2025-06-01 11:42 UTC

This package is auto-updated.

Last update: 2025-06-01 11:44:02 UTC


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

  1. Generate models, migrations, and seeder:
php artisan iran-cities:generate --all
  1. Run migrations:
php artisan migrate
  1. Run the seeder:
php artisan db:seed --class="Database\Seeders\IranProvincesAndCitiesSeeder"
  1. 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.