restore paymentable reliably when restoring invoice with attached payment
This commit is contained in:
parent
ec95d087f1
commit
c05a0dd598
|
|
@ -12,6 +12,7 @@
|
||||||
namespace App\Services\Invoice;
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Paymentable;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
|
|
@ -74,10 +75,14 @@ class HandleRestore extends AbstractService
|
||||||
private function restorePaymentables()
|
private function restorePaymentables()
|
||||||
{
|
{
|
||||||
$this->invoice->payments->each(function ($payment) {
|
$this->invoice->payments->each(function ($payment) {
|
||||||
$payment->paymentables()
|
|
||||||
->where('paymentable_type', '=', 'invoices')
|
Paymentable::query()
|
||||||
->where('paymentable_id', $this->invoice->id)
|
->withTrashed()
|
||||||
->update(['deleted_at' => false]);
|
->where('payment_id', $payment->id)
|
||||||
|
->where('paymentable_type', '=', 'invoices')
|
||||||
|
->where('paymentable_id', $this->invoice->id)
|
||||||
|
->update(['deleted_at' => false]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue