db->table('t_coatingmachinedetails') ->select('t_coatingmachinedetails.*, JSON_ARRAYAGG( JSON_OBJECT( "client_given_name", t_batchcard_files.client_file_name, "filename", t_batchcard_files.filename, "batchCardId" , t_batchcard_files.id, "coating_id", t_batchcard_files.coating_id ) ) as batchcard_files') ->join('t_batchcard_files', 't_batchcard_files.coating_id = t_coatingmachinedetails.id', 'left') ->where('t_coatingmachinedetails.date >=', $startDate) ->where('t_coatingmachinedetails.date <=', $endDate) ->groupBy('t_coatingmachinedetails.id') ->orderBy('t_coatingmachinedetails.date', 'asc') ->get() ->getResultArray(); return $result; } public function isShiftExists($date, $shift) { $result = $this->db->table('t_coatingmachinedetails') ->where('date', $date) ->where('shift', $shift) ->where('is_active', 1) ->get() ->getResultArray(); return $result; } }