PHPackages                             novasemantics/nepal-locations-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. novasemantics/nepal-locations-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

novasemantics/nepal-locations-laravel
=====================================

A Laravel-friendly PHP package that provides structured data for Nepal's administrative divisions, including provinces, districts and cities. Easily integrate location-based hierarchies into your Laravel apps.

1.0.0(1y ago)06MITPHPPHP ^8.2||^8.3||^8.4CI passing

Since May 30Pushed 1y agoCompare

[ Source](https://github.com/novasemantics/nepal-locations-laravel)[ Packagist](https://packagist.org/packages/novasemantics/nepal-locations-laravel)[ Docs](https://github.com/novasemantics/nepal-locations-laravel)[ GitHub Sponsors](https://github.com/novasemantics)[ RSS](/packages/novasemantics-nepal-locations-laravel/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (12)Versions (2)Used By (0)

Nepal Locations (Laravel Package)
=================================

[](#nepal-locations-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d8a2fbc4b6ae6def01d9a7452ff893c381e9b3afc69f1e845587f5258bebb688/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f766173656d616e746963732f6e6570616c2d6c6f636174696f6e732d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/novasemantics/nepal-locations-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f30c989a52ac5a205989be1440d4c5a69546995545ce4e25d9f4b37d579f78d7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e6f766173656d616e746963732f6e6570616c2d6c6f636174696f6e732d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/novasemantics/nepal-locations-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a660be892d369995db1840af12c8cf31b9fb4a95d598823d2cc936f76ca1c25b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e6f766173656d616e746963732f6e6570616c2d6c6f636174696f6e732d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/novasemantics/nepal-locations-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/0ee6cd76ddc0f02eecfa20f3e52c2902a303f06224915f605aa3b33171308f78/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6f766173656d616e746963732f6e6570616c2d6c6f636174696f6e732d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/novasemantics/nepal-locations-laravel)

---

NepalLocations is a Laravel package providing **Nepal’s geographical data** — provinces, districts, cities, and their hierarchical relationships. It offers a structured way to access and manipulate this data using Laravel's powerful query builder API.

---

Features
--------

[](#features)

- Eloquent models: `Province`, `District`, `City`
- Collision free table names with configurable prefixes
- Enum support for `CityType`
- One-command import with:
    - Full or partial import options
    - Smart update/merge of existing data
    - Selective field overriding
- JSON-driven immutable source data
- Useful relationships:
    - `Province → Districts & Cities`
    - `District → Cities`

---

Installation
------------

[](#installation)

Require the package via Composer:

```
composer require novasemantics/nepal-locations-laravel
```

You can install the package's assets and configuration file using the following artisan command:

```
php artisan nepal-locations-laravel:install
```

- The installation command will publish the package's configuration file to `config/nepal-locations-laravel.php`.
- It will also publish the migration files to `database/migrations/`.
- Then you will be asked to run the migrations to create the necessary database tables.
- Finally, you will be prompted to run the import command to populate the database with initial data.

---

How to Get Updated Data
-----------------------

[](#how-to-get-updated-data)

The package is maintained with the latest geographical data of Nepal. To get the most recent data, you can update the package using Composer:

```
composer update novasemantics/nepal-locations-laravel
```

Then you can manually run the import command to refresh the data in your database:

```
php artisan import:geo-data
```

Fresh Import option will be provided to overwrite existing data with the latest from the package, if you have been using the data in foreign keys or relationships, you can choose to update only the fields you need without affecting the existing relationships. As the ID's for geo tables are immutable, you can safely update without worrying about breaking changes.

⚙️ Models Overview
------------------

[](#️-models-overview)

### Province

[](#province)

The `Province` model represents Nepal's administrative provinces. It contains information about the province's name, area, population, and its districts.

### District

[](#district)

The `District` model represents the districts within a province. It includes details such as the district's name, area, population, and the province it belongs to.

### City

[](#city)

The `City` model represents cities within a district. It includes the city's name, type (e.g., Metropolitan, Sub-Metropolitan), area, population, and the district it belongs to.

### Data Structure

[](#data-structure)

FieldTypeDescriptionModels`id`IntegerUnique identifierAll`name`StringEnglish name of the locationAll`name_np`StringNepali name of the locationAll`lat`FloatLatitudeAll`lng`FloatLongitudeAll`area`FloatArea in square kilometersAll`population`IntegerPopulation countAll`type`EnumType of city (e.g., Metropolitan, Sub-Metropolitan)City`wards`IntegerNumber of administrative wardsCity`province_id`IntegerForeign key to ProvinceDistrict, City`district_id`IntegerForeign key to DistrictCity`additional_fields`ArrayAdditional fields like website,phoneAll---

📥 Importing Geo Data
--------------------

[](#-importing-geo-data)

Use the following artisan command:

```
php artisan import:geo-data
```

### What it does:

[](#what-it-does)

- Interactive CLI to:
    - Choose which data types to import (`provinces`, `districts`, `cities`)
    - Perform **fresh import** or **update** mode
    - Select specific fields to override on update
    - Confirm before execution

### Example:

[](#example)

```
php artisan import:geo-data

```

> You’ll be prompted with interactive options for a safe and flexible import experience.

---

💡 Example Usage
---------------

[](#-example-usage)

### Get all districts of Province ID 3

[](#get-all-districts-of-province-id-3)

```
use NovaSemantics\NepalLocations\Models\Province;

$province = Province::find(3);
$districts = $province->districts;

// Or directly get cities of the province
$cities = $province->cities;
```

### Get all cities of a district

[](#get-all-cities-of-a-district)

```
use NovaSemantics\NepalLocations\Models\District;

$district = District::find(12);
$cities = $district->cities;
```

### Get all metropolitan cities

[](#get-all-metropolitan-cities)

```
use NovaSemantics\NepalLocations\Enums\CityType;
use NovaSemantics\NepalLocations\Models\City;

$cities = City::where('type', CityType::Metropolitan)->get();
```

---

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance46

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

401d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/998f6899ac416d2fde69e4de3bc278dd67de3269aa14d2d5839f0c8f76397482?d=identicon)[novasemantics-official](/maintainers/novasemantics-official)

---

Top Contributors

[![novasemantics-official](https://avatars.githubusercontent.com/u/214112830?v=4)](https://github.com/novasemantics-official "novasemantics-official (2 commits)")

---

Tags

laravelnepalgeodatanovasemanticsnepali-data-apinepali-datanepal-locations-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/novasemantics-nepal-locations-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/novasemantics-nepal-locations-laravel/health.svg)](https://phpackages.com/packages/novasemantics-nepal-locations-laravel)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
