Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

MdMostaFizurRahaman/ecommerce

29 stars
3 code files
View MdMostaFizurRahaman/ecommerce on GitHub

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 GitHub
use App\Enums\AddressType;
 
class Delivery extends Model
{
//
public function getBillingAddressAttribute()
{
if ($this->address) {
return $this->address->where('type', AddressType::BILLING_ADDRESS())->first();
}
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.