fix data setting get datatable using api token
This commit is contained in:
45
app/Console/Commands/ClearDatabaseSessions.php
Normal file
45
app/Console/Commands/ClearDatabaseSessions.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ClearDatabaseSessions extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'session:clear-db {--force : Force the operation without confirmation}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clear all database sessions';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (!$this->option('force') && !$this->confirm('Are you sure you want to clear all database sessions?')) {
|
||||
$this->info('Operation cancelled.');
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
$count = DB::table('sessions')->count();
|
||||
DB::table('sessions')->delete();
|
||||
|
||||
$this->info("Successfully cleared {$count} database sessions.");
|
||||
return 0;
|
||||
} catch (\Exception $e) {
|
||||
$this->error('Failed to clear database sessions: ' . $e->getMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user