15
15
use Jurager \Teams \Events \TeamMemberUpdated ;
16
16
use Jurager \Teams \Models \Owner ;
17
17
use Jurager \Teams \Support \Facades \Teams ;
18
+ use RuntimeException ;
18
19
19
20
trait HasMembers
20
21
{
@@ -113,17 +114,17 @@ public function hasUser(object $user): bool
113
114
public function addUser (object $ user , string $ role_keyword ): void
114
115
{
115
116
if ($ user ->id === $ this ->owner ->id ) {
116
- throw new \ RuntimeException (__ ('Owner already belongs to the team. ' ));
117
+ throw new RuntimeException (__ ('Owner already belongs to the team. ' ));
117
118
}
118
119
119
120
if ($ this ->hasUser ($ user )) {
120
- throw new \ RuntimeException (__ ('User already belongs to the team. ' ));
121
+ throw new RuntimeException (__ ('User already belongs to the team. ' ));
121
122
}
122
123
123
124
$ role = $ this ->getRole ($ role_keyword );
124
125
125
126
if (!$ role ) {
126
- throw new \ RuntimeException (__ ('Unable to find a role :role within team. ' , ['role ' => $ role_keyword ]));
127
+ throw new RuntimeException (__ ('Unable to find a role :role within team. ' , ['role ' => $ role_keyword ]));
127
128
}
128
129
129
130
// Dispatch an event before attaching the user
@@ -146,17 +147,17 @@ public function addUser(object $user, string $role_keyword): void
146
147
public function updateUser (object $ user , string $ role_keyword ): void
147
148
{
148
149
if ($ user ->id === $ this ->owner ->id ) {
149
- throw new \ RuntimeException (__ ('You may not change the team owner. ' ));
150
+ throw new RuntimeException (__ ('You may not change the team owner. ' ));
150
151
}
151
152
152
153
if (!$ this ->hasUser ($ user )) {
153
- throw new \ RuntimeException (__ ('User not belongs to the team. ' ));
154
+ throw new RuntimeException (__ ('User not belongs to the team. ' ));
154
155
}
155
156
156
157
$ role = $ this ->getRole ($ role_keyword );
157
158
158
159
if (!$ role ) {
159
- throw new \ RuntimeException (__ ('Unable to find a role :role within team. ' , ['role ' => $ role_keyword ]));
160
+ throw new RuntimeException (__ ('Unable to find a role :role within team. ' , ['role ' => $ role_keyword ]));
160
161
}
161
162
162
163
// Update the user role for the team
@@ -176,11 +177,11 @@ public function updateUser(object $user, string $role_keyword): void
176
177
public function deleteUser (object $ user ): void
177
178
{
178
179
if ($ user ->id === $ this ->owner ->id ) {
179
- throw new \ RuntimeException (__ ('You may not remove the team owner. ' ));
180
+ throw new RuntimeException (__ ('You may not remove the team owner. ' ));
180
181
}
181
182
182
183
if (!$ this ->hasUser ($ user )) {
183
- throw new \ RuntimeException (__ ('User not belongs to the team. ' ));
184
+ throw new RuntimeException (__ ('User not belongs to the team. ' ));
184
185
}
185
186
186
187
// Detach the user from the team
@@ -228,7 +229,7 @@ public function userHasPermission(object $user, string|array $permissions, bool
228
229
/**
229
230
* Check if the team has a specific role by ID or code or any roles at all
230
231
*
231
- * @param string|null $keyword The role ID or code to check for. If null, checks for any roles.
232
+ * @param int| string|null $keyword The role ID or code to check for. If null, checks for any roles.
232
233
* @return bool
233
234
*/
234
235
public function hasRole (int |string |null $ keyword = null ): bool
@@ -263,7 +264,7 @@ public function getRole(int|string $keyword): object|null
263
264
public function addRole (string $ code , array $ permissions , string |null $ name = null , string |null $ description = null ): object
264
265
{
265
266
if ($ this ->hasRole ($ code )) {
266
- throw new \ RuntimeException ("Role with code ' $ code' already exists. " );
267
+ throw new RuntimeException ("Role with code ' $ code' already exists. " );
267
268
}
268
269
269
270
$ role = $ this ->roles ()->create ([
@@ -325,7 +326,7 @@ public function deleteRole(int|string $keyword): bool
325
326
/**
326
327
* Check if the team has a specific group by ID or code or any groups at all
327
328
*
328
- * @param string|null $keyword The role ID or code to check for. If null, checks for any groups.
329
+ * @param int| string|null $keyword The role ID or code to check for. If null, checks for any groups.
329
330
* @return bool
330
331
*/
331
332
public function hasGroup (int |string |null $ keyword = null ): bool
@@ -359,7 +360,7 @@ public function getGroup(int|string $keyword): object|null
359
360
public function addGroup (string $ code , array $ permissions = [], string |null $ name = null ): object
360
361
{
361
362
if ($ this ->hasGroup ($ code )) {
362
- throw new \ RuntimeException ("Group with code ' $ code' already exists. " );
363
+ throw new RuntimeException ("Group with code ' $ code' already exists. " );
363
364
}
364
365
365
366
$ group = $ this ->groups ()->create ([
0 commit comments