Files
UNIT3D-Community-Edition/app/Console/Commands/AutoRecycleAudits.php
T
Roardom ddfcf4f6b1 refactor: use bulk deletes in console commands
Should improve performance a bit.
2024-08-18 06:57:36 +00:00

54 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Console\Commands;
use App\Models\Audit;
use Exception;
use Illuminate\Console\Command;
use Throwable;
class AutoRecycleAudits extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'auto:recycle_audits';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Recycle Audits Once X Days Old.';
/**
* Execute the console command.
*
* @throws Exception|Throwable If there is an error during the execution of the command.
*/
final public function handle(): void
{
Audit::query()
->where('created_at', '<', now()->subDays(config('audit.recycle')))
->delete();
$this->comment('Automated Audit Recycle Command Complete');
}
}