- 월간 캘린더 뷰 (사원별 필터, 날짜 클릭 등록, HTMX 월 이동) - 일괄 등록 (다수 사원 체크박스 선택 후 일괄 등록, upsert 처리) - 사원별 월간 요약 (상태별 카운트 + 총 근무시간 집계 테이블) - 초과근무 알림 (주 48h 경고 / 52h 위험 배너) - 근태 승인 워크플로우 (신청→승인→근태 레코드 자동 생성) - 자동 결근 처리 (매일 23:50 스케줄러, 주말 제외) - 연차 관리 연동 (휴가 등록 시 leave_balances 자동 차감) - GPS 출퇴근 UI (테이블 GPS 아이콘 + 상세 모달) - 탭 네비게이션 (목록/캘린더/요약/승인) HTMX 기반 전환
94 lines
2.1 KiB
PHP
94 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models\HR;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class AttendanceRequest extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'attendance_requests';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'user_id',
|
|
'request_type',
|
|
'start_date',
|
|
'end_date',
|
|
'reason',
|
|
'status',
|
|
'approved_by',
|
|
'approved_at',
|
|
'reject_reason',
|
|
'json_details',
|
|
];
|
|
|
|
protected $casts = [
|
|
'tenant_id' => 'int',
|
|
'user_id' => 'int',
|
|
'approved_by' => 'int',
|
|
'start_date' => 'date',
|
|
'end_date' => 'date',
|
|
'approved_at' => 'datetime',
|
|
'json_details' => 'array',
|
|
];
|
|
|
|
public const TYPE_MAP = [
|
|
'vacation' => '휴가',
|
|
'businessTrip' => '출장',
|
|
'remote' => '재택',
|
|
'fieldWork' => '외근',
|
|
];
|
|
|
|
public const STATUS_MAP = [
|
|
'pending' => '대기',
|
|
'approved' => '승인',
|
|
'rejected' => '반려',
|
|
];
|
|
|
|
public const STATUS_COLORS = [
|
|
'pending' => 'amber',
|
|
'approved' => 'emerald',
|
|
'rejected' => 'red',
|
|
];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
public function approver(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'approved_by');
|
|
}
|
|
|
|
public function getTypeLabelAttribute(): string
|
|
{
|
|
return self::TYPE_MAP[$this->request_type] ?? $this->request_type;
|
|
}
|
|
|
|
public function getStatusLabelAttribute(): string
|
|
{
|
|
return self::STATUS_MAP[$this->status] ?? $this->status;
|
|
}
|
|
|
|
public function getStatusColorAttribute(): string
|
|
{
|
|
return self::STATUS_COLORS[$this->status] ?? 'gray';
|
|
}
|
|
|
|
public function scopeForTenant($query, ?int $tenantId = null)
|
|
{
|
|
$tenantId = $tenantId ?? session('selected_tenant_id');
|
|
if ($tenantId) {
|
|
return $query->where($this->table.'.tenant_id', $tenantId);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
}
|