<?php namespace App\Services; use App\Models\{AttendanceMonthLock,Holiday,RemoteWorkRequest}; use Carbon\Carbon; class AttendancePolicyService {public function periodLocked(Carbon $date):bool{return AttendanceMonthLock::where('period',$date->format('Y-m'))->exists();} public function holiday(Carbon $date):bool{return Holiday::whereDate('holiday_date',$date)->exists();} public function weeklyOff($worker,Carbon $date):bool{$days=$worker->shift?->weekly_off_days??[];if(is_string($days))$days=json_decode($days,true)?:[];return in_array(strtolower($date->format('l')),array_map('strtolower',$days),true);} public function remoteApproved(int $userId,Carbon $date):bool{return RemoteWorkRequest::where('user_id',$userId)->whereDate('work_date',$date)->where('status','approved')->exists();}}