-
Notifications
You must be signed in to change notification settings - Fork 2
/
PresentationForm.php
55 lines (44 loc) · 1.3 KB
/
PresentationForm.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
<?php
namespace App\Livewire\Forms;
use App\Models\Company;
use App\Models\Presentation;
use Livewire\Attributes\Validate;
use Livewire\Form;
class PresentationForm extends Form
{
public $presentation;
#[Validate('required|string|max:255|min:1')]
public $name;
#[Validate('required|string|max:300|min:1')]
public $description;
#[Validate(['required', 'in:workshop,lecture'])]
public $type;
#[Validate(['required', 'numeric', 'min:1', 'max:999'])]
public $max_participants;
#[Validate(['required', 'numeric', 'exists:difficulties,id'])]
public $difficulty_id;
/**
* Sets the presentation details per each field
* @param Presentation $presentation
* @return void
*/
public function setCompany(Presentation $presentation)
{
$this->presentation = $presentation;
$this->name = $presentation->name;
$this->description = $presentation->description;
$this->type = $presentation->type;
$this->max_participants = $presentation->max_participants;
$this->difficulty_id = $presentation->difficulty_id;
}
/**
* Updates the company details with the new data
* @return void
*/
public function update()
{
$this->presentation->update(
$this->all()
);
}
}