NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

type is a string-backed enum, RoundlyConsulting\Addresses\Enums\AddressType. The column stores the backing value and the model casts it back to the enum:

CaseValuelabel()
AddressType::DefaultdefaultDefault
AddressType::BillingbillingBilling
AddressType::ShippingshippingShipping
AddressType::HomehomeHome
AddressType::WorkworkWork
AddressType::OfficeofficeOffice
use RoundlyConsulting\Addresses\Enums\AddressType;

AddressType::Office->value;     // 'office'
AddressType::Office->label();   // 'Office'
AddressType::cases();           // all six cases
AddressType::from('billing');   // AddressType::Billing

Types are enum-only across the whole public API — the builder, AddressData, createAddress(), the read helpers, the scopes and the facade all take an AddressType. Passing a plain string such as 'office' is a type error, so upgrade older string-based calls to the matching case.

From request input

Validate with Laravel’s enum rule, or convert an untrusted string yourself and fail with the package’s typed exception. Apart from a misconfigured default_type, the package never throws InvalidAddressTypeException itself — it exists for exactly this boundary:

use Illuminate\Validation\Rule;
use RoundlyConsulting\Addresses\Enums\AddressType;
use RoundlyConsulting\Addresses\Exceptions\InvalidAddressTypeException;

// validate with Laravel's enum rule…
$request->validate(['type' => ['required', Rule::enum(AddressType::class)]]);
$type = $request->enum('type', AddressType::class);

// …or convert an untrusted string yourself and fail with the package's typed exception
$type = AddressType::tryFrom($input)
    ?? throw InvalidAddressTypeException::for($input);

Select options

label() returns a fixed English label, handy for a type picker:

use RoundlyConsulting\Addresses\Enums\AddressType;

$options = collect(AddressType::cases())
    ->mapWithKeys(fn (AddressType $type) => [$type->value => $type->label()])
    ->all();
// ['default' => 'Default', 'billing' => 'Billing', 'shipping' => 'Shipping', …]

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

By 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.