tjenestetorget/norwegian-zip-codes

Laravel models for Norwegian zip codes, municipalities and counties. Includes an artisan command to update data from the official authority.
20,911
Install
composer require tjenestetorget/norwegian-zip-codes
Latest Version:1.2
PHP:>=5.5
License:MIT
Last Updated:Dec 27, 2022
Links: GitHub  ·  Packagist
Maintainer: ideea

This package was sponsored by tjenestetorget.no / helsetjenester.no

What?

This package contains models, migrations and commands to automatically setup and update the administrative hierarchy of zip codes, municipalities and counties in Norway.

How

Install the package

composer require "tjenestetorget/norwegian-zip-codes"

Add service provider
Add NorwegianZipCodes\Providers\NorwegianZipCodesServiceProvider in config/app.php to the 'providers' array

Copy migrations to your migrations folder

php artisan vendor:publish --provider="NorwegianZipCodes\Providers\NorwegianZipCodesServiceProvider"

Run migrations

php artisan migrate

Seed the database

php artisan db:seed --class="NorwegianZipCodeSeeds"

Populate the database

php artisan zip_codes:update

Start using the models

	$zip_code     = \NorwegianZipCodes\Models\ZipCode::find('7340');
	$municipality = $zip_code->municipality;
	$county       = $municipality->county

ER diagram

ER diagram

Note

All IDs for counties, municipalities and zip_codes are strings. This is because officially the IDs are zero padded, fixed size. (4 for zip codes and municipalities, 2 for counties)

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

637,827,751 9,703
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
1.2 >=5.5 ~5.1 MIT
1.1 >=5.5 ~5.1 MIT
1.0 >=5.5 ~5.1 MIT