-
composer.json
Open in GitHub{ // "require": { "php": "^7.3|^8.0", // "myclabs/php-enum": "^1.8" }, // }
-
app/Enums/AddressType.php
Open in GitHub/** * @method static AppearanceType PRESENT_ADDRESS() * @method static AppearanceType PERMANENT_ADDRESS() * @method static AppearanceType BILLING_ADDRESS() * @method static AppearanceType SHIPPING_ADDRESS() */ class AddressType extends Enum { private const PRESENT_ADDRESS = 'present_address'; private const PERMANENT_ADDRESS = 'permanent_address'; private const BILLING_ADDRESS = 'billing_address'; private const SHIPPING_ADDRESS = 'shipping_address'; }
-
app/Models/Delivery.php
Open in GitHubuse App\Enums\AddressType; class Delivery extends Model { // public function getBillingAddressAttribute() { if ($this->address) { return $this->address->where('type', AddressType::BILLING_ADDRESS())->first(); } } // }