Fix transaction delete issue

This commit is contained in:
harshjagad20
2022-03-02 12:17:31 +05:30
parent ffa7906382
commit 5720803116
2 changed files with 10 additions and 1 deletions

View File

@ -300,6 +300,10 @@ class Company extends Model implements HasMedia
if ($this->invoices()->exists()) { if ($this->invoices()->exists()) {
$this->invoices->map(function ($invoice) { $this->invoices->map(function ($invoice) {
$this->checkModelData($invoice); $this->checkModelData($invoice);
if ($invoice->transactions()->exists()) {
$invoice->transactions()->delete();
}
}); });
$this->invoices()->delete(); $this->invoices()->delete();

View File

@ -139,7 +139,12 @@ class Customer extends Authenticatable implements HasMedia
} }
if ($customer->invoices()->exists()) { if ($customer->invoices()->exists()) {
$customer->invoices()->delete(); $customer->invoices->map(function ($invoice) {
if ($invoice->transactions()->exists()) {
$invoice->transactions()->delete();
}
$invoice->delete();
});
} }
if ($customer->payments()->exists()) { if ($customer->payments()->exists()) {