Это моя попытка:
$calendar = Calendar::leftJoin("class", "class.start_date", "<=", "calendar.date")
->leftJoin("student", "class.id", "student.class_id")
->where("student.id", $id)
->select("calendar.date");
$calendarQuery = $calendar->toSql();
$temperature = Temperature
::leftJoin("temperature_type", "temperature.temperature_type_id", "temperature_type.id")
->where("temperature.student_id", $id)
->select("temperature.student_id", "temperature.id", DB::raw("date(temperature.created_at) as date"), DB::raw("cast(temperature.created_at as time) as time"), "status", "temperature_type_id", "temperature_type.name as temperature_type", "temperature.temperature", "temperature.unit")
->orderby("temperature.id");
$temperatureQuery = $temperature->toSql();
$return['output'] = DB::table(DB::raw("($temperatureQuery) AS temp"))
->rightJoin(DB::raw("($calendarQuery) AS cal"),
function($join) use ($calendar){
$join->on("temp.date", "=" ,"cal.date")
->addBinding($calendar->getBindings());
})->get();
return $return;
Я бы хотел присоединиться к этим двум красноречивым запросам.
Я нашел эту проблему. Какие-либо предложения?