---
title: "The Address model — Addresses for Laravel | Roundly"
description: "Attributes, casts, the owner relation, JSON meta and the formatted() one-line label on the Address model."
url: https://roundly-consulting.com/open-source/docs/addresses-for-laravel/address-model
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Addresses for Laravel](https://roundly-consulting.com/open-source/docs/addresses-for-laravel.md)

# The Address model

RoundlyConsulting\\Addresses\\Address is a regular Eloquent model backing the addresses table. It is non-final so you can extend it, uses HasFactory and SoftDeletes, and leaves every attribute mass-assignable ($guarded = \[\]).

| Attribute | Type | Notes |
| --- | --- | --- |
| `id` | int | Primary key. |
| `addressable_type / addressable_id` | string / key | The owner’s morph pair. |
| `is_primary` | bool | Cast to bool. |
| `type` | AddressType | Cast to the enum. |
| `name` | ?string | Optional label. |
| `city, street, postal_code` | ?string | The address lines. |
| `country_iso` | ?string | The stored ISO code. |
| `country_name` | ?string | Accessor — resolved through a CountryResolver, never stored. |
| `meta` | ?Collection | Collection cast over the JSON column. |
| `created_at, updated_at, deleted_at` | ?Carbon | Timestamps and the soft-delete marker. |

```php
$address->addressable;          // the owning model (Customer, Company, …)
$address->type;                 // AddressType::Billing
$address->type->label();        // 'Billing'
$address->is_primary;           // bool
$address->country_iso;          // 'SK'
$address->country_name;         // resolved name, or null without a resolver
```

## Meta

meta holds anything address-related that does not deserve a column — a floor, a gate code, delivery notes. It is stored as JSON and cast back to an Illuminate\\Support\\Collection, or null when nothing was set:

```php
$address = $customer->newAddress()
    ->in('Bratislava')->at('Somewhere 1')->postalCode('81101')->country('SK')
    ->meta(['floor' => 3, 'gate_code' => '1234'])
    ->save();

$address->meta->get('floor');        // 3
$address->meta?->get('gate_code');  // '1234' — meta is null when none was set
```

## Formatted label

formatted() builds a single-line label from the populated parts — name, street, postal code with city, and the country code — skipping any that are empty. Pass a separator to replace the default comma:

```php
$payer->primaryAddress()?->formatted();
// "HQ, Somewhere 1, 81101 Bratislava, SK"

$address->formatted(' | ');
// "HQ | Somewhere 1 | 81101 Bratislava | SK"

// empty parts are skipped — the same kind of address without a name:
// "Main 2, 04001 Košice, SK"
```

The label uses the ISO code, not a resolved country name, so it is the same whether or not a CountryResolver is bound.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/addresses-for-laravel.md)
