raihanafroz / zkteco

ZKTeco Laravel Library
155 stars 58 forks source link

How to get latest attendance record? because in in companies with 10000 or employee it is not efficient to get all the record #6

Open rubik360accounting opened 3 years ago

jmrashed commented 7 months ago
static public function getTodaysRecords(ZKTeco $self)
    {
        // Get all attendance records from the device
        $attendanceData = self::get($self);

        // Get today's date
        $currentDate = date('Y-m-d');

        // Filter attendance data for today
        $todaysAttendance = array_filter($attendanceData, function($record) use ($currentDate) {
            // Assuming the date format in the attendance data is 'Y-m-d H:i:s'
            return substr($record['timestamp'], 0, 10) === $currentDate;
        });

        return $todaysAttendance;
    }

Add this method to get todays records

NazarAli commented 4 months ago

@jmrashed but in this code i must load all data in my app and then filter it . this take a lot of time