mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-08-07 10:01:47 -04:00
Refactor registerForm method in Register.php
This commit is contained in:
parent
dbf5b4166e
commit
379ac0991d
@ -60,7 +60,8 @@ class Register extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->state['initial_completed'] = true;
|
$this->state['initial_completed'] = true;
|
||||||
$this->state['register_form'] = true;
|
|
||||||
|
$this->registerForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(array $data)
|
public function register(array $data)
|
||||||
@ -82,6 +83,31 @@ class Register extends Component
|
|||||||
$this->dispatch('purchase.next');
|
$this->dispatch('purchase.next');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function registerForm()
|
||||||
|
{
|
||||||
|
$count = collect($this->subscription->company->client_registration_fields ?? [])
|
||||||
|
->filter(fn($field) => $field['required'] === true || $field['visible'] === true)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
if ($count === 0) {
|
||||||
|
$service = new ClientRegisterService(
|
||||||
|
company: $this->subscription->company,
|
||||||
|
);
|
||||||
|
|
||||||
|
$client = $service->createClient([]);
|
||||||
|
$contact = $service->createClientContact([], $client);
|
||||||
|
|
||||||
|
auth()->guard('contact')->loginUsingId($contact->id, true);
|
||||||
|
|
||||||
|
$this->dispatch('purchase.context', property: 'contact', value: $contact);
|
||||||
|
$this->dispatch('purchase.next');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->steps['register_form'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
if (auth()->guard('contact')->check()) {
|
if (auth()->guard('contact')->check()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user