Total Complexity | 2 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class Form extends Component |
||
9 | { |
||
10 | /** |
||
11 | * Request method. |
||
12 | */ |
||
13 | public string $method; |
||
14 | |||
15 | /** |
||
16 | * Form method spoofing to support PUT, PATCH and DELETE actions. |
||
17 | * https://laravel.com/docs/master/routing#form-method-spoofing |
||
18 | */ |
||
19 | public bool $spoofMethod = false; |
||
20 | |||
21 | /** |
||
22 | * Create a new component instance. |
||
23 | * |
||
24 | * @return void |
||
25 | */ |
||
26 | public function __construct(string $method = 'POST') |
||
27 | { |
||
28 | $this->method = strtoupper($method); |
||
29 | |||
30 | $this->spoofMethod = in_array($this->method, ['PUT', 'PATCH', 'DELETE']); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Returns a boolean wether the error bag is not empty. |
||
35 | * |
||
36 | * @param string $bag |
||
37 | * @return boolean |
||
38 | */ |
||
39 | public function hasError($bag = 'default'): bool |
||
44 | } |
||
45 | } |
||
46 |