public static function get_pregunta_no_respondida($email, $codreto, $id_area) { $respuesta = new stdClass(); $pregunta = Pregunta::whereNotIn("CODPREGUNTA", function ($query) use($email, $codreto) { $query->select("CODPREGUNTA")->from("RESPONDIDAS_RETO")->where("EMAIL", "=", "{$email}")->where("CODRETO", "=", "{$codreto}"); })->where("CODAREA", "=", "{$id_area}")->orderByRaw("rand()")->first(); if ($pregunta) { $pregunta->encabezado; //$pregunta->opciones()->orderByRaw("rand()"); $pregunta->opciones; $respuesta->pregunta = $pregunta; $respuesta->result = true; } else { $respuesta->result = false; $respuesta->mensaje = "Error. Revise los datos enviados."; } return $respuesta; }