You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
protected$signature = 'cache:clear-roles-permissions {--user-id= : Clear cache for specific user} {--all : Clear all user caches by incrementing version}';
20
+
21
+
/**
22
+
* The console command description.
23
+
*
24
+
* @var string
25
+
*/
26
+
protected$description = 'Clear role and permission caches';
27
+
28
+
/**
29
+
* Execute the console command.
30
+
*/
31
+
publicfunctionhandle(): int
32
+
{
33
+
$userId = $this->option('user-id');
34
+
$clearAll = $this->option('all');
35
+
36
+
if ($userId) {
37
+
$user = User::find($userId);
38
+
if (! $user) {
39
+
$this->error("User with ID {$userId} not found.");
40
+
41
+
return1;
42
+
}
43
+
44
+
$user->clearCache();
45
+
$this->info("Cache cleared for user: {$user->name} (ID: {$userId})");
46
+
} elseif ($clearAll) {
47
+
$this->clearAllUserCaches();
48
+
$this->info('All user caches cleared by incrementing cache version.');
49
+
} else {
50
+
$this->clearGlobalCaches();
51
+
$this->info('Global role and permission caches cleared successfully.');
0 commit comments