-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCompanyBasicForm.php
74 lines (62 loc) · 1.91 KB
/
CompanyBasicForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace App\Livewire\Registration;
use Illuminate\View\View;
use Livewire\Attributes\On;
use Livewire\Attributes\Validate;
use Livewire\Component;
class CompanyBasicForm extends Component
{
#[Validate(['required', 'string', 'min:3', 'max:255'])]
public string $companyName;
#[Validate(['required', 'string', 'min:3', 'max:255'])]
public string $companyDescription;
#[Validate(['required', 'string', 'regex:/^www\.[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}$/', 'min:3', 'max:255'])]
public string $companyWebsite;
#[Validate(['nullable'])]
#[Validate('phone:INTERNATIONAL,NL', message: 'Invalid phone number')]
public string $companyPhoneNumber = '';
/**
* Dispatches an event to the parent component to go back
* @return void
*/
public function goBack()
{
$this->dispatch('go-back', formName: 'CompanyBasicInfoForm');
}
/**
* Updates the phone number by catching the update from the child
*
* @param $phoneNumber
* @return void
*/
#[On('updated-phone-number')]
public function updatePhoneNumber($phoneNumber)
{
$this->companyPhoneNumber = $phoneNumber;
}
/**
* Dispatches an event to the parent to go next
* @return void
*/
public function goNext()
{
if (strlen($this->companyPhoneNumber) <= 5) {
$this->companyPhoneNumber = '';
}
$this->validate();
$this->dispatch('go-next', formName: 'CompanyBasicInfoForm', input: [
'company_name' => $this->companyName,
'company_description' => $this->companyDescription,
'company_phone_number' => $this->companyPhoneNumber,
'company_website' => $this->companyWebsite
]);
}
/**
* Renders the component
* @return View
*/
public function render(): View
{
return view('livewire.registration.company-basic-form');
}
}