custom summarizer

I've been trying to make a custom Summarizer with the using method but it doesn't receive a $record as a parameter and don't know how to pass the fk value, this is the code:
->using(
function (Builder $query) {
$records = $this->table->getRelationshipQuery()->whereKey('patient_id');
dd($records);
$sum = DB::table('service_patients')
->select(DB::raw('sum(services.cost_per_unit) as sumService'))
->leftJoin('services', 'service_patients.service_id', '=', 'services.id')
->where('service_patients.patient_id', 1)
->get();
return $sum[0]->sumService;
}
)
->using(
function (Builder $query) {
$records = $this->table->getRelationshipQuery()->whereKey('patient_id');
dd($records);
$sum = DB::table('service_patients')
->select(DB::raw('sum(services.cost_per_unit) as sumService'))
->leftJoin('services', 'service_patients.service_id', '=', 'services.id')
->where('service_patients.patient_id', 1)
->get();
return $sum[0]->sumService;
}
)
I only need to pass the
service_patients.patient_id
service_patients.patient_id
value but don''t know how. Any ideas?
1 Reply
ingmontoya
ingmontoyaOP14mo ago
Any one? up?
Want results from more Discord servers?
Add your server