PHPackages                             maggomann/addressable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. maggomann/addressable

ActiveLibrary[Database &amp; ORM](/categories/database)

maggomann/addressable
=====================

This Laravel package provides a minimal trait Addressable to add eloquent models using these addresses.

v0.2.2(2y ago)06.4k↓100%[2 PRs](https://github.com/Maggomann/addressable/pulls)1MITPHPPHP ^8.1

Since Aug 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Maggomann/addressable)[ Packagist](https://packagist.org/packages/maggomann/addressable)[ Docs](https://github.com/maggomann/addressable)[ RSS](/packages/maggomann-addressable/feed)WikiDiscussions v0.x Synced 1mo ago

READMEChangelog (6)Dependencies (15)Versions (12)Used By (1)

[![GitHub Tests Action Status](https://camo.githubusercontent.com/25d5ebb5538eec3aed50c2fdb12178f48f23fddca6943f9fb4791a49cc9df3a0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4d6167676f6d616e6e2f6164647265737361626c652f72756e2d74657374732e796d6c3f6272616e636825334176302e78266c6162656c3d7465737473)](https://github.com/Maggomann/addressable/actions?query=workflow%3Arun-tests+branch%3Av0.x) [![Total Downloads](https://camo.githubusercontent.com/99f0bf9b6dbff5b29cbee48be0b1bcd72c756a67bdde6e2093f1fea938a2b48f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6167676f6d616e6e2f6164647265737361626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maggomann/addressable)

---

addressable
-----------

[](#addressable)

This package provides a minimal trait Addressable to add eloquent models using these addresses for laraval. The package will be extended over time. It was directly outsourced as a package before I start using this class modified in different projects.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require maggomann/addressable
```

You can install anything with the command

```
php artisan addressable:install
php artisan migrate
```

Or

---

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="addressable-migrations"
php artisan migrate
```

Optionally, you can publish the configuration file with:

```
php artisan vendor:publish --tag="addressable-config"
```

Optionally, you can publish the translation files with:

```
php artisan vendor:publish --tag="addressable-translations"
```

How is it used?
---------------

[](#how-is-it-used)

```
use Illuminate\Database\Eloquent\Model;
use Maggomann\Addressable\Traits\Addressable;

class Player extends Models
{
    use Addressable;
}

//...
//...

$exampleAttributes = [
    'first_name' => 'first name',
    'last_name' => 'last name',
    'name' => 'name',
    'street_address' => 'street address',
    'street_addition' => 'street addition',
    'postal_code' => 'postal code',
    'city' => 'city',
    'country_code' => 'de',
    'state' => null,
    'company' => null,
    'job_title' => null,
    'is_preferred' => true,
    'is_main' => true,
];

$address = new Address();
$address->fill($exampleAttributes);
$address->withCategory($categoryIdOrCategoryClass);
$address->withGender($genderIdOrGenderClass);

Player::query()
    ->findOrFail(1)
    ->address()
    ->save($address);
```

```
use Illuminate\Database\Eloquent\Model;
use Maggomann\Addressable\Traits\Addressable;

class Player extends Models
{
    use Addressable;
}

//...
//...

$exampleAttributes = [
    'first_name' => 'first name',
    'last_name' => 'last name',
    'name' => 'name',
    'street_address' => 'street address',
    'street_addition' => 'street addition',
    'postal_code' => 'postal code',
    'city' => 'city',
    'country_code' => 'de',
    'state' => null,
    'company' => null,
    'job_title' => null,
    'is_preferred' => true,
    'is_main' => true,
];

$addressOne = new Address();
$addressOne->fill($exampleAttributes);
$addressOne->withCategory($categoryIdOrCategoryClass);
$addressOne->withGender($genderIdOrGenderClass);

$addressTwo = new Address();
$addressTwo->fill($exampleAttributes);
$addressTwo->withCategory($categoryIdOrCategoryClass);
$addressTwo->withGender($genderIdOrGenderClass);

$player = Player::query()->findOrFail(1);

$player->addresses()->save($addressOne);
$player->addresses()->save($addressTwo);

// or

$player->addresses()->saveMany(
    collect([
        $addressOne,
        $addressTwo,
    ])
);
```

```
use Illuminate\Database\Eloquent\Model;
use Maggomann\Addressable\Domain\Actions\UpdateOrCreateAddressAction;
use Maggomann\Addressable\Traits\Addressable;

class Player extends Models
{
    use Addressable;
}

//...
//...

$exampleAttributes = [
    'first_name' => 'first name',
    'last_name' => 'last name',
    'name' => 'name',
    'street_address' => 'street address',
    'street_addition' => 'street addition',
    'postal_code' => 'postal code',
    'city' => 'city',
    'country_code' => 'de',
    'state' => null,
    'company' => null,
    'job_title' => null,
    'is_preferred' => true,
    'is_main' => true,
];

$newAddress = app(UpdateOrCreateAddressAction::class)->execute(
    $player,
    AddressData::from($exampleAttributes)
);

// or

$updatedAddress = app(UpdateOrCreateAddressAction::class)->execute(
    $player,
    AddressData::from($exampleAttributes)
    $player->addresses()->first()
);
```

### The address table currently comes with the following attributes:

[](#the-address-table-currently-comes-with-the-following-attributes)

```
    'attributes' => [
        'addresses' => [
            'category_id' => 'address type',
            'gender_id' => 'salutation',
            'first_name' => 'first name',
            'last_name' => 'last name',
            'name' => 'first_name', 'last_name' => 'last_name',
            'street_address' => 'streets and no.',
            'street_addition' => 'street addition',
            'postal_code' => 'postal code',
            'city' => 'city',
            'country_code' => 'country',
            'state' => 'federal state',
            'company' => 'company',
            'job_title' => 'job title',
            'is_preferred' => 'prefer',
            'is_main' => 'is main address',
            'latitude' => 'latitude',
            'longitude' => 'longitude',
        ],
    ],
```

### Preinstalled salutations

[](#preinstalled-salutations)

By default, these are located in the table: address\_genders

```
    'address_genders' => [
        'title' => [
            'male' => 'Mr.',
            'female' => 'Ms.',
            'diverse' => 'Various',
        ],
    ],
```

### Preinstalled categories

[](#preinstalled-categories)

By default, these are located in the table: address\_categories

```
    'address_categories' => [
        'title' => [
            'standard' => 'Default address',
            'billing' => 'Billing addres',
            'shipping' => 'Delivery address',
        ],
    ],
```

Testing
-------

[](#testing)

```
composer test
composer test:pest-coverage
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Marco Ehrt](https://github.com/Maggomann)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~31 days

Total

7

Last Release

1093d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/765f102aaeb3fa64356cc95d41c27f798bd5c6c25948cb20de248fcc953b1192?d=identicon)[Maggomann](/maintainers/Maggomann)

---

Top Contributors

[![Maggomann](https://avatars.githubusercontent.com/u/4435288?v=4)](https://github.com/Maggomann "Maggomann (58 commits)")

---

Tags

laraveladdressablemaggomann

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/maggomann-addressable/health.svg)

```
[![Health](https://phpackages.com/badges/maggomann-addressable/health.svg)](https://phpackages.com/packages/maggomann-addressable)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
