From 7c796802be2ee303076999d3c18884d117fed776 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sat, 4 Oct 2025 12:39:13 +0200 Subject: [PATCH] new: make invoice still keep the old addresses when their address gets deleted in profile --- app/Models/Shop/CustomerAddress.php | 2 ++ app/Models/Shop/Invoice.php | 2 +- app/Models/Shop/Order.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Models/Shop/CustomerAddress.php b/app/Models/Shop/CustomerAddress.php index 0613aa69..cefc3c04 100644 --- a/app/Models/Shop/CustomerAddress.php +++ b/app/Models/Shop/CustomerAddress.php @@ -3,9 +3,11 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\SoftDeletes; class CustomerAddress extends Model { + use SoftDeletes; protected $guarded = ['id']; protected $table = 'shop_customer_addresses'; diff --git a/app/Models/Shop/Invoice.php b/app/Models/Shop/Invoice.php index 70f85dcd..107ce175 100644 --- a/app/Models/Shop/Invoice.php +++ b/app/Models/Shop/Invoice.php @@ -39,7 +39,7 @@ class Invoice extends Model public function address(): BelongsTo { - return $this->belongsTo(CustomerAddress::class, 'invoice_address_id'); + return $this->belongsTo(CustomerAddress::class, 'invoice_address_id')->withTrashed(); } public function scopeByCustomer($query, $customerId) diff --git a/app/Models/Shop/Order.php b/app/Models/Shop/Order.php index 45346c9a..366a6b35 100644 --- a/app/Models/Shop/Order.php +++ b/app/Models/Shop/Order.php @@ -29,7 +29,7 @@ class Order extends Model public function delivery_address(): BelongsTo { - return $this->belongsTo(CustomerAddress::class, 'delivery_address_id'); + return $this->belongsTo(CustomerAddress::class, 'delivery_address_id')->withTrashed(); } public function delivery(): BelongsTo