Files
sam-manage/app/Console/Commands/MarkAbsentEmployees.php

36 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Services\HR\AttendanceService;
use Illuminate\Console\Command;
class MarkAbsentEmployees extends Command
{
protected $signature = 'attendance:mark-absent {--date= : 대상 날짜 (YYYY-MM-DD), 기본값: 오늘}';
protected $description = '영업일에 출근 기록이 없는 사원을 자동 결근 처리';
public function handle(AttendanceService $service): int
{
$date = $this->option('date') ?: now()->toDateString();
$this->info("결근 처리 시작: {$date}");
$result = $service->markAbsentees($date);
if ($result['skipped_weekend']) {
$this->info('주말이므로 건너뜁니다.');
} elseif ($result['count'] > 0) {
$this->info("{$result['count']}명 결근 처리 완료");
foreach ($result['names'] as $name) {
$this->line(" - {$name}");
}
} else {
$this->info('결근 처리 대상이 없습니다 (모든 사원에 기록이 있음)');
}
return self::SUCCESS;
}
}