-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCompanyForm.php
66 lines (52 loc) · 1.5 KB
/
CompanyForm.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
<?php
namespace App\Livewire\Forms;
use App\Models\Company;
use Livewire\Attributes\Validate;
use Livewire\Form;
class CompanyForm extends Form
{
public Company $company;
#[Validate('required')]
public string $name;
#[Validate('required')]
public string $description;
#[Validate('required')]
public string $website;
#[Validate('required|phone:INTERNATIONAL, NL')]
public string $phone_number;
#[Validate(['required','regex:/^[1-9][0-9]{3} ?(?!sa|sd|ss)[a-z]{2}$/i'])]
public string $postcode;
#[Validate(['required','regex:/(\w?[0-9]+[a-zA-Z0-9\- ]*)$/i'])]
public string $house_number;
#[Validate('required')]
public string $street;
#[Validate('required')]
public string $city;
/**
* Sets the company details per each field
* @param Company $company
* @return void
*/
public function setCompany(Company $company)
{
$this->company = $company;
$this->name = $company->name;
$this->description = $company->description;
$this->website = $company->website;
$this->phone_number = $company->phone_number;
$this->postcode = $company->postcode;
$this->house_number = $company->house_number;
$this->street = $company->street;
$this->city = $company->city;
}
/**
* Updates the company details with the new data
* @return void
*/
public function update()
{
$this->company->update(
$this->all()
);
}
}