2021-04-08 17:11:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-04-08 17:11:14 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-04-08 17:11:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
|
2021-06-07 03:06:31 +02:00
|
|
|
use App\Libraries\MultiDB;
|
2021-04-08 17:11:14 +02:00
|
|
|
use App\Models\RecurringInvoice;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class RecurringInvoiceCancellation extends Component
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var RecurringInvoice
|
|
|
|
*/
|
|
|
|
public $invoice;
|
|
|
|
|
2021-06-07 03:06:31 +02:00
|
|
|
public $company;
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2021-06-07 03:06:31 +02:00
|
|
|
public function mount()
|
|
|
|
{
|
|
|
|
MultiDB::setDb($this->company->db);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return render('components.livewire.recurring-invoice-cancellation');
|
|
|
|
}
|
|
|
|
|
2021-04-08 17:11:14 +02:00
|
|
|
public function processCancellation()
|
|
|
|
{
|
|
|
|
if ($this->invoice->subscription) {
|
2021-04-15 07:36:50 +02:00
|
|
|
return $this->invoice->subscription->service()->handleCancellation($this->invoice);
|
2021-04-08 17:11:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return redirect()->route('client.recurring_invoices.request_cancellation', ['recurring_invoice' => $this->invoice->hashed_id]);
|
|
|
|
}
|
|
|
|
}
|