1 | <?php |
||
23 | trait CrudTrait |
||
24 | { |
||
25 | /** |
||
26 | * Create a new tag. |
||
27 | * |
||
28 | * @param array $input |
||
29 | * |
||
30 | * @return mixed |
||
31 | */ |
||
32 | 1 | public function createTag(array $input) |
|
33 | { |
||
34 | 1 | $input['group'] = !array_key_exists('group', $input) ? 0 : $input['group']; |
|
35 | |||
36 | 1 | return $this->fill($input)->save(); |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * Delete tag. |
||
41 | * |
||
42 | * @return bool|null |
||
43 | * |
||
44 | * @throws \Exception |
||
45 | */ |
||
46 | public function delete() |
||
56 | |||
57 | abstract public function fill(array $attributes); |
||
58 | } |
||
59 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: