You are joining multiple tables. By default, all fields/columns from those tables will be included. We don't really know what created_at
field from which table is used.
Medicals::join("patient_referral", "medicals.trx_id", "=", "patient_referral.trx_id")
->where(function ($q) use ($startdate, $enddate) {
$q->whereBetween('medicals.created_at', [$startdate, $enddate])->get();
})
// I select all fields from medicals table. You might want to update this later.
->selectRaw('medicals.*')
->leftJoin("patients", "medicals.patients_id", "=", "patients.id")
->join("tests", "medicals.tests_id", "=", "tests.id")
->get()
->groupBy(function (Medicals $item) {
return Carbon::parse($item->created_at)->format('m');;
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…