Laravel Addressable is a polymorphic Laravel package, for addressbook management. You can add addresses to any eloquent model with ease.

1.1.0 2021-04-03 16:13 UTC

This package is auto-updated.

Last update: 2022-01-03 21:49:02 UTC


It is a polymorphic Laravel package, for addressbook management. You can add addresses to any eloquent model with ease.

This is based on Rinvex Addresses package


  1. Install the package via composer:

    composer require nunomazer/laravel-addressable
  2. Publish resources (migrations and config files):

    php artisan vendor:publish
  3. Edit config file config/addressable.php if you need to change database table name:

     // Addresses Database Tables
     'tables' => [
         'addresses' => 'addresses',
  4. Execute migrations via the following command:

    php artisan migrate
  5. Done!


To add addresses support to your eloquent models simply use \NunoMazer\Addressable\Traits\Addressable trait.


namespace App\Models;


use NunoMazer\Addressable\Traits\Addressable;

class User extends Model
    use Addressable;

Manage your addresses

// Get instance of your model
$user = new \App\Models\User::find(1);

// Create a new address
// note that this are fake informations
    'label' => 'Default Address',
    'organization' => 'DN42',
    'country_code' => 'br',
    'state' => 'Paraná',
    'city' => 'Ponta Grossa',
    'line_1' => 'Av. Carlos Cavalcanti',
    'number' => '200',
    'complement' => 'Apt #44',
    'postal_code' => '84000-100',
    'extra' => [
            'ibge_code' => '300'    
    'latitude' => '31.2467601',
    'longitude' => '29.9020376',
    'is_primary' => true,
    'is_billing' => true,
    'is_shipping' => true,

// Create multiple new addresses

// Find an existing address
$address = app('addressable.address')->find(1);

// Update an existing address
    'label' => 'Default Work Address',

// Delete address

// Alternative way of address deletion
$user->addresses()->where('id', 123)->first()->delete();

Manage your addressable model

The API is intuitive and very straight forward, so let's give it a quick look:

// Get instance of your model
$user = new \App\Models\User::find(1);

// Get attached addresses collection

// Get attached addresses query builder

// Scope Primary Addresses
$primaryAddresses = app('addressable.address')->isPrimary()->get();

// Scope Billing Addresses
$billingAddresses = app('addressable.address')->isBilling()->get();

// Scope Shipping Addresses
$shippingAddresses = app('addressable.address')->isShipping()->get();

// Scope Addresses in the given country
$egyptianAddresses = app('addressable.address')->InCountry('eg')->get();

// Find all users within 5 kilometers radius from the latitude/longitude 31.2467601/29.9020376
$fiveKmAddresses = \App\Models\User::findByDistance(5, 'kilometers', '31.2467601', '29.9020376')->get();

// Alternative method to find users within certain radius
$user = new \App\Models\User();
$users = $user->lat('31.2467601')->lng('29.9020376')->within(5, 'kilometers')->get();


Refer to the Changelog for a full history of the project.


The following support channels are available at your fingertips:

Contributing & Protocols

Thank you for considering contributing to this project! The contribution guide can be found in

Bug reports, feature requests, and pull requests are very welcome.

Security Vulnerabilities

If you discover a security vulnerability within this project, please open an issue.


This software is released under The MIT License (MIT).