I want to have a table in the view that shows all the registration types associated with a conference, the price of each one and the number of registrations sold of each registration type.
For example if the conference with id "1" has two registration types with this columns:
- rtype1 (name), 0.00$ (price), 20 (capacity)
- rtype2 (name), 5.00$ (price), 10 (capacity)
And there are 20 participants registered in the rtype1 and 5 registered in the rtype 2 I want to show a table like:
Registration Type Price Sold/capacity
rtype1 0.00$ 20/20
rtype2 5.00$ 5/10
Im not understanding how to properly achieve that. For now I have this query to get each registration type and the count of each registration type:
$participantsOfEachType = Participant::
select(DB::raw('registration_type_id, count(registration_type_id)'))
->groupBy('registration_type_id')->get();
This query returns the results below. But is not considering a specific conference. Do you know what is necessary to consider a specific conference id so is possible to show the results in a table in view like its in the above table example?
Collection {#271 ▼
#items: array:2 [▼
0 => Participant {#282 ▼
...
#attributes: array:2 [▼
"registration_type_id" => 1
"count(registration_type_id)" => 2
]
...
}
1 => Participant {#279 ▼
...
#attributes: array:2 [▼
"registration_type_id" => 2
"count(registration_type_id)" => 2
]
...
}
]
}