These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Admin\Model; |
||
3 | |||
4 | use Redaxscript\Model as BaseModel; |
||
5 | |||
6 | /** |
||
7 | * parent class to provide the admin group model |
||
8 | * |
||
9 | * @since 4.0.0 |
||
10 | * |
||
11 | * @package Redaxscript |
||
12 | * @category Model |
||
13 | * @author Henry Ruhs |
||
14 | */ |
||
15 | |||
16 | class Group extends BaseModel\Group |
||
17 | { |
||
18 | /** |
||
19 | * is unique by id and alias |
||
20 | * |
||
21 | * @since 4.0.0 |
||
22 | * |
||
23 | * @param int $groupId identifier of the group |
||
24 | * @param string $groupAlias alias of the group |
||
25 | * |
||
26 | * @return bool |
||
27 | */ |
||
28 | |||
29 | public function isUniqueByIdAndAlias(int $groupId = null, string $groupAlias = null) : bool |
||
30 | { |
||
31 | return !$this->getByAlias($groupAlias)?->id || $this->getByAlias($groupAlias)?->id === $this->getById($groupId)?->id; |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
32 | } |
||
33 | |||
34 | /** |
||
35 | * create the group by array |
||
36 | * |
||
37 | * @since 4.0.0 |
||
38 | * |
||
39 | * @param array $createArray array of the create |
||
40 | * |
||
41 | * @return bool |
||
42 | */ |
||
43 | |||
44 | public function createByArray(array $createArray = []) : bool |
||
45 | { |
||
46 | return $this |
||
47 | ->query() |
||
48 | ->create() |
||
49 | ->set($createArray) |
||
50 | ->save(); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * update the group by id and array |
||
55 | * |
||
56 | * @since 4.0.0 |
||
57 | * |
||
58 | * @param int $groupId identifier of the group |
||
59 | * @param array $updateArray array of the update |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | |||
64 | public function updateByIdAndArray(int $groupId = null, array $updateArray = []) : bool |
||
65 | { |
||
66 | return $this |
||
67 | ->query() |
||
68 | ->whereIdIs($groupId) |
||
69 | ->findOne() |
||
70 | ->set($updateArray) |
||
71 | ->save(); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * enable the group by id |
||
76 | * |
||
77 | * @since 4.0.0 |
||
78 | * |
||
79 | * @param int $groupId identifier of the group |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | |||
84 | public function enableById(int $groupId = null) : bool |
||
85 | { |
||
86 | return $this |
||
87 | ->query() |
||
88 | ->whereIdIs($groupId) |
||
89 | ->findOne() |
||
90 | ->set('status', 1) |
||
91 | ->save(); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * disable the group by id |
||
96 | * |
||
97 | * @since 4.0.0 |
||
98 | * |
||
99 | * @param int $groupId identifier of the group |
||
100 | * |
||
101 | * @return bool |
||
102 | */ |
||
103 | |||
104 | public function disableById(int $groupId = null) : bool |
||
105 | { |
||
106 | return $this |
||
107 | ->query() |
||
108 | ->whereIdIs($groupId) |
||
109 | ->findOne() |
||
110 | ->set('status', 0) |
||
111 | ->save(); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * delete the group by id |
||
116 | * |
||
117 | * @since 4.0.0 |
||
118 | * |
||
119 | * @param int $groupId identifier of the group |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | |||
124 | public function deleteById(int $groupId = null) : bool |
||
125 | { |
||
126 | return $this |
||
127 | ->query() |
||
128 | ->whereIdIs($groupId) |
||
129 | ->deleteMany(); |
||
130 | } |
||
131 | } |
||
132 |