2021-06-25 09:15:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-06-25 09:15:57 +02:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
2023-12-13 17:52:49 +01:00
|
|
|
namespace App\Livewire\PaymentMethods;
|
2021-06-25 09:15:57 +02:00
|
|
|
|
|
|
|
use App\Libraries\MultiDB;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class UpdateDefaultMethod extends Component
|
|
|
|
{
|
|
|
|
/** @var \App\Models\Company */
|
|
|
|
public $company;
|
|
|
|
|
|
|
|
/** @var \App\Models\ClientGatewayToken */
|
|
|
|
public $token;
|
|
|
|
|
|
|
|
/** @var \App\Models\Client */
|
|
|
|
public $client;
|
|
|
|
|
|
|
|
public function mount()
|
|
|
|
{
|
|
|
|
$this->company = $this->client->company;
|
|
|
|
|
|
|
|
MultiDB::setDb($this->company->db);
|
|
|
|
|
2023-08-07 00:23:13 +02:00
|
|
|
// $this->is_disabled = $this->token->is_default;
|
2021-06-25 09:15:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function makeDefault(): void
|
|
|
|
{
|
|
|
|
if ($this->token->is_default) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->client->gateway_tokens()->update(['is_default' => 0]);
|
|
|
|
|
|
|
|
$this->token->is_default = 1;
|
|
|
|
$this->token->save();
|
|
|
|
|
2023-12-13 17:52:49 +01:00
|
|
|
$this->dispatch('UpdateDefaultMethod::method-updated');
|
2021-06-25 09:15:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return render('components.livewire.update-default-payment-method');
|
|
|
|
}
|
|
|
|
}
|