Download the PHP package apriil/postal-codes without Composer
On this page you can find all versions of the php package apriil/postal-codes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download apriil/postal-codes
More information about apriil/postal-codes
Files in apriil/postal-codes
Package postal-codes
Short Description Eloquent model for Norwegian postal codes
License MIT
Homepage https://github.com/apriil-digital/postal-codes
Informations about the package postal-codes
Norwegian Postal Codes
An Eloquent model with every Norwegian postal code (postnummer), place name (poststed), and delivery category, ready to query in Laravel or any PHP app that uses Illuminate Database.
The dataset lives in memory via Sushi—no migrations, seeders, or external API calls. Install the package and query postal codes like any other Eloquent model.
Features
- 5,122 postal codes bundled in the package
- Standard Eloquent API —
find,where,exists, relationships, and the rest - Zero database setup — Sushi builds a temporary SQLite table from the embedded data
- Leading zeros preserved — postal codes are stored as four-character strings (e.g.
0001,7030) - Delivery categories — each code is tagged as street address, PO box, both, or service point via a typed
Categoryenum
Prerequisites
- PHP 8.1 or newer
- PDO SQLite extension (
pdo_sqlite) — required by Sushi - Laravel 8.69 or newer
Installation
Install via Composer:
Usage
Import the model and use familiar Eloquent methods.
Look up a postal code
Filter by category
Each postal code has a category that describes what kind of delivery it supports. The value is cast to the Category backed enum:
| Enum case | Stored value | Meaning |
|---|---|---|
Category::Address |
G |
Street address delivery only |
Category::Mailbox |
P |
PO box (postboks) delivery only |
Category::Both |
B |
Both street address and PO box |
Category::ServicePoint |
S |
Service point / pickup location |
Most codes are street-address (G) or PO box (P). Both and ServicePoint are less common but matter when you need to restrict which codes users can enter (for example, only G for home delivery forms).
Validate that a postal code exists
Find all codes for a place
Many places share one name (e.g. several codes for Oslo):
Use in validation (Laravel)
Autocomplete or select options
Relationships
Treat PostalCode like any other Eloquent model. For example, a User model can reference a postal code:
Model reference
| Column | Type | Description |
|---|---|---|
id |
string | Four-digit Norwegian postal code (primary key) |
name |
string | Place name (poststed) |
category |
Category |
Delivery type (G, P, B, or S) — see above |
The model does not use timestamps (created_at / updated_at).
License
MIT © Apriil Digital