Update clear cache all add command to clear session files also

This commit is contained in:
Afiq Hamzah
2024-08-08 14:36:13 +08:00
parent 67943c81ff
commit 9d4afa825d
3 changed files with 71 additions and 1 deletions
@@ -4,7 +4,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
class ClearAllCaches extends Command
class ClearCachesAll extends Command
{
/**
* The name and signature of the console command.
@@ -34,6 +34,7 @@ class ClearAllCaches extends Command
$this->call('optimize:clear');
$this->call('package:discover');
$this->call('queue:clear');
$this->call('clear-sessions');
$this->info("All caches have been cleared.");;
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use File;
class ClearSessions extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'clear-sessions';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear all session files';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$files = File::files(storage_path('framework/sessions'));
foreach ($files as $file) {
File::delete($file);
}
$this->info('Session files cleared successfully.');
return 0;
}
}