@@ -189,6 +189,8 @@ public function syncRoles(...$roles)
189
189
*/
190
190
public function hasRole ($ roles , string $ guard = null ): bool
191
191
{
192
+ $ this ->loadMissing ('roles ' );
193
+
192
194
if (is_string ($ roles ) && false !== strpos ($ roles , '| ' )) {
193
195
$ roles = $ this ->convertPipeToArray ($ roles );
194
196
}
@@ -248,6 +250,8 @@ public function hasAnyRole(...$roles): bool
248
250
*/
249
251
public function hasAllRoles ($ roles , string $ guard = null ): bool
250
252
{
253
+ $ this ->loadMissing ('roles ' );
254
+
251
255
if (is_string ($ roles ) && false !== strpos ($ roles , '| ' )) {
252
256
$ roles = $ this ->convertPipeToArray ($ roles );
253
257
}
@@ -282,6 +286,8 @@ public function hasAllRoles($roles, string $guard = null): bool
282
286
*/
283
287
public function hasExactRoles ($ roles , string $ guard = null ): bool
284
288
{
289
+ $ this ->loadMissing ('roles ' );
290
+
285
291
if (is_string ($ roles ) && false !== strpos ($ roles , '| ' )) {
286
292
$ roles = $ this ->convertPipeToArray ($ roles );
287
293
}
@@ -311,6 +317,8 @@ public function getDirectPermissions(): Collection
311
317
312
318
public function getRoleNames (): Collection
313
319
{
320
+ $ this ->loadMissing ('roles ' );
321
+
314
322
return $ this ->roles ->pluck ('name ' );
315
323
}
316
324
0 commit comments