35 lines
782 B
PHP
35 lines
782 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use App\Models\BiometricAttendance;
|
|
use Carbon\Carbon;
|
|
|
|
class ClearOldBiometricData extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'biometric:clear-old';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Clear biometric attendances older than 30 days';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$date = Carbon::now()->subDays(30);
|
|
$deleted = BiometricAttendance::where('punch_time', '<', $date)->delete();
|
|
$this->info("Deleted {$deleted} old biometric attendance records.");
|
|
}
|
|
}
|