Add logs:clear command (#509)

This commit is contained in:
Saeed Vaziry 2025-02-27 22:19:50 +01:00 committed by GitHub
parent f54c754971
commit d8ece27964
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,26 @@
<?php
namespace App\Console\Commands;
use App\Models\ServerLog;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
class ClearLogsCommand extends Command
{
protected $signature = 'logs:clear';
protected $description = 'Clear all server logs';
public function handle(): void
{
$this->info('Clearing logs...');
ServerLog::query()->delete();
File::cleanDirectory(Storage::disk('server-logs')->path(''));
$this->info('Logs cleared!');
}
}