Total Complexity | 3 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class PermissionForm extends Form |
||
12 | { |
||
13 | /** |
||
14 | * The permission to update. |
||
15 | * |
||
16 | * @var Permission|null |
||
17 | */ |
||
18 | public ?Permission $permission = null; |
||
19 | |||
20 | /** |
||
21 | * The name of the permission. |
||
22 | * |
||
23 | * @var string|null |
||
24 | */ |
||
25 | public ?string $name = null; |
||
26 | |||
27 | /** |
||
28 | * The description of the permission. |
||
29 | * |
||
30 | * @var string|null |
||
31 | */ |
||
32 | public ?string $description = null; |
||
33 | |||
34 | protected function rules(): array |
||
35 | { |
||
36 | return [ |
||
37 | 'name' => [ |
||
38 | 'required', |
||
39 | 'min:5', |
||
40 | Rule::unique('permissions')->ignore($this->permission) |
||
41 | ], |
||
42 | 'description' => 'required|min:10', |
||
43 | ]; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Function to store the model. |
||
48 | * |
||
49 | * @return Permission |
||
50 | */ |
||
51 | public function create(): Permission |
||
52 | { |
||
53 | $properties = [ |
||
54 | 'name', |
||
55 | 'description' |
||
56 | ]; |
||
57 | |||
58 | return Permission::create($this->only($properties)); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Function to update the model. |
||
63 | * |
||
64 | * @return Permission |
||
65 | */ |
||
66 | public function update(): Permission |
||
73 | } |
||
74 | } |
||
75 |