1. Go to this page and download the library: Download apriil/postal-codes library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Apriil\PostalCodes\Enums\Category;
use Apriil\PostalCodes\PostalCode;
// Street-address codes only
$streetCodes = PostalCode::where('category', Category::Address)->get();
// PO box codes in Oslo
$osloPostboxes = PostalCode::where('name', 'Oslo')
->where('category', Category::Mailbox)
->get();
// Compare on the model
$postal = PostalCode::find('0050');
$postal->category === Category::Address; // true
use Apriil\PostalCodes\PostalCode;
class User extends Model
{
public function postalCode()
{
return $this->belongsTo(PostalCode::class, 'postal_code', 'id');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.