phaza / laravel-norwegian-zip-codes by phaza

Laravel models for Norwegian zip codes, municipalities and counties. Includes an artisan command to update data from the official authority.
838
1
2
Package Data
Maintainer Username: phaza
Maintainer Contact: peter.haza@gmail.com (Peter Haza)
Package Create Date: 2015-02-23
Package Last Update: 2021-06-21
Language: PHP
License: MIT
Last Refreshed: 2024-11-20 03:03:35
Package Statistics
Total Downloads: 838
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

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 "phaza/laravel-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)