I am using this query to get a list of users with additional data, as of now I output the ‘section-points’ with the withsum
$rider = Rider::query()
->withSum([
'statistics' => function($query) {$query->whereIn('key', [
'jumping-sectionpoints',
'dressage-sectionpoints',
'driving-sectionpoints',
'reining-sectionpoints',
'grand-prix-jumping-sectionpoints',
'grand-prix-dressage-sectionpoints',
]);}], 'value' )
->with('user')->orderByDesc('xp')->get();
I want to another whereIn that goes through the statistics relation and outputs the ‘value’ from ‘key’, ‘foal-births’ as additional data. I’ve tried a bunch of options to keep it within eager loading but I can’t seem to figure it out (it’s probably an easy fix).
If I add another whereIn/withSum it would both output in ‘statistics_sum_value’ what would just cause problems cause I need to be able to call them separately.
this is how I currently call the withsum in the query:
<div class="r-table__item w-1/6">{{ number_format($rider->statistics_sum_value, 0, ',', '.') ?? 0 }}</div>
any help would be amazing. Thank you in advance
Mathios Ramaker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.