/** * @param $day string of course day * @param $time_start string of course start time * @param $time_end string of course end time */ public static function isAbsentFillable($day, $time_start, $time_end, $kode_seksi, $noreg) { //get current time in Indonesia $current_day = trans('messages.' . date('l')); //get current time $current_time = date('H:i'); //first condition current time must be in interval course time $stat = (bool) DB::select('select ? between ? and ? as result', [$current_time, $time_start, $time_end])[0]->result; //second condition current day must be within course day $stat2 = strcmp($current_day, $day) == 0; //third condition, check in presences table whether current slot already exist $current_slot = WaktuKuliah::getKodeWaktuByTime($current_time); if (is_null($current_slot)) { return 0; } $current_date = date('Y-m-d'); $recorded_slot = Presence::getKodeWaktuByDate($current_date, $kode_seksi, $noreg); //if(is_null($recorded_slot)) // return 0; //insertable if current slot different from recorded slot $stat3 = strcmp($current_slot, $recorded_slot) != 0; $final_stat = $stat && $stat2 && $stat3; return $final_stat; }
/** * Round about solution to debug lambda function * @param $validator * @return bool */ protected function checkCompositeUnique($validator) { $pertemuan = $validator->getData()['pertemuan_ke']; $seksi = $validator->getData()['seksi']; $stat = Presence::isExist($pertemuan, $seksi); if ($stat) { return true; } return false; }