function make($data) { $month = Month::ForMonth('January')->first(); $config['month_id'] = $month->id; $config['member_id'] = Session::get('memberId'); $config['date'] = $data['date']; if (array_key_exists('check_in', $data)) { $config['check_in'] = $data['check_in']; $attendance = Attendance::ForUniqueCheck($config['member_id'], $config['date'])->first(); if (empty($attendance)) { Attendance::create($config); } else { throw new Exception('You Already have check In for the day'); } } if (array_key_exists('check_out', $data)) { $config['check_out'] = $data['check_out']; // foreach($data as $key => $value) // { // $this->is_empty($value); // } // $this->is_valid($this->checkInFlag); $attendance = Attendance::ForUniqueCheck($config['member_id'], $config['date'])->first(); if (empty($attendance)) { throw new Exception('You Havent check in yet'); } if ($attendance->check_out === '00:00:00') { $attendance->update($data); } else { throw new Exception('You Already have check out for the day'); } } }