All packages
Addresses for Laravel
API resource
RoundlyConsulting\Addresses\Http\Resources\AddressResource is a JsonResource with an explicit, stable shape:
use App\Models\Customer;
use Illuminate\Support\Facades\Route;
use RoundlyConsulting\Addresses\Address;
use RoundlyConsulting\Addresses\Http\Resources\AddressResource;
Route::get('/customers/{customer}/addresses', function (Customer $customer) {
return AddressResource::collection($customer->addresses);
});
Route::get('/addresses/{address}', function (Address $address) {
return AddressResource::make($address);
});| Key | Value |
|---|---|
id | The address id. |
type | The type’s string value, e.g. billing. |
name, city, street, postal_code | The stored lines. |
country_iso | The stored ISO code. |
country_name | The resolved name, or null without a CountryResolver. |
is_primary | Boolean primary flag. |
formatted | The one-line label from formatted(). |
meta | The meta collection, or null. |
created_at, updated_at | Timestamps. |
country_name reflects the bound CountryResolver (null without one) and formatted is the label from formatted(). The resource is final — for a different shape, write your own JsonResource over the Address model.
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 cryptoBy donating, you agree to our donation terms.
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.