1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Refactor SubscriptionPlanSwitch class and add handleRff method

This commit is contained in:
Benjamin Beganović 2024-02-09 19:20:33 +01:00
parent 735cc552af
commit 3dfe5db4fd

View File

@ -44,7 +44,7 @@ class SubscriptionPlanSwitch extends Component
/**
* @var ClientContact
*/
public $contact;
public ClientContact $contact;
/**
* @var array
@ -66,6 +66,7 @@ class SubscriptionPlanSwitch extends Component
'invoice' => null,
'company_gateway_id' => null,
'payment_method_id' => null,
'show_rff' => false,
];
/**
@ -75,6 +76,12 @@ class SubscriptionPlanSwitch extends Component
public $company;
public ?string $first_name;
public ?string $last_name;
public ?string $email;
public function mount()
{
MultiDB::setDb($this->company->db);
@ -84,6 +91,31 @@ class SubscriptionPlanSwitch extends Component
$this->methods = $this->contact->client->service()->getPaymentMethods($this->amount);
$this->hash = Str::uuid()->toString();
$this->state['show_rff'] = auth()->guard('contact')->user()->showRff();
$this->first_name = $this->contact->first_name;
$this->last_name = $this->contact->last_name;
$this->email = $this->contact->email;
}
public function handleRff()
{
$this->validate([
'first_name' => ['required'],
'last_name' => ['required'],
'email' => ['required', 'email'],
]);
$this->contact->update([
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'email' => $this->email,
]);
$this->state['show_rff'] = false;
}
public function handleBeforePaymentEvents(): void