mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor Register component in BillingPortal
This commit is contained in:
parent
7f2a3e1523
commit
f004282310
@ -14,17 +14,8 @@ namespace App\Livewire\BillingPortal\Authentication;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use App\Models\Subscription;
|
use App\Models\Subscription;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Factory\ClientFactory;
|
|
||||||
use App\Jobs\Mail\NinjaMailerJob;
|
|
||||||
use App\DataMapper\ClientSettings;
|
|
||||||
use App\Mail\Subscription\OtpCode;
|
|
||||||
use App\Jobs\Mail\NinjaMailerObject;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use App\Repositories\ClientRepository;
|
|
||||||
use App\Repositories\ClientContactRepository;
|
|
||||||
|
|
||||||
class Register extends Component
|
class Register extends Component
|
||||||
{
|
{
|
||||||
@ -43,9 +34,7 @@ class Register extends Component
|
|||||||
'register_form' => false,
|
'register_form' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
public array $registration_fields = [];
|
public function initial(): void
|
||||||
|
|
||||||
public function initial()
|
|
||||||
{
|
{
|
||||||
$this->validateOnly('email', ['email' => 'required|bail|email:rfc']);
|
$this->validateOnly('email', ['email' => 'required|bail|email:rfc']);
|
||||||
|
|
||||||
@ -60,7 +49,7 @@ class Register extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->state['initial_completed'] = true;
|
$this->state['initial_completed'] = true;
|
||||||
|
|
||||||
$this->registerForm();
|
$this->registerForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,8 +58,8 @@ class Register extends Component
|
|||||||
$service = new ClientRegisterService(
|
$service = new ClientRegisterService(
|
||||||
company: $this->subscription->company,
|
company: $this->subscription->company,
|
||||||
);
|
);
|
||||||
|
|
||||||
$rules = $service->rules();
|
$rules = $service->rules();
|
||||||
|
|
||||||
$data = Validator::make($data, $rules)->validate();
|
$data = Validator::make($data, $rules)->validate();
|
||||||
|
|
||||||
@ -95,7 +84,7 @@ class Register extends Component
|
|||||||
);
|
);
|
||||||
|
|
||||||
$client = $service->createClient([]);
|
$client = $service->createClient([]);
|
||||||
$contact = $service->createClientContact([], $client);
|
$contact = $service->createClientContact(['email' => $this->email], $client);
|
||||||
|
|
||||||
auth()->guard('contact')->loginUsingId($contact->id, true);
|
auth()->guard('contact')->loginUsingId($contact->id, true);
|
||||||
|
|
||||||
@ -105,7 +94,7 @@ class Register extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->steps['register_form'] = true;
|
return $this->state['register_form'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user