Skip to content

Instantly share code, notes, and snippets.

@abishekrsrikaanth
Last active March 9, 2020 20:47
Show Gist options
  • Save abishekrsrikaanth/81264b456449a96de47547a668c7027a to your computer and use it in GitHub Desktop.
Save abishekrsrikaanth/81264b456449a96de47547a668c7027a to your computer and use it in GitHub Desktop.
<?php
public function fields(Request $request)
{
return [
// ... All your other fields here
GroupByTool::make()
->usingModel(EventRegistration::class)
->selectColumns([
"shirt_size",
"COUNT('shirt_size') as total_count",
])
->groupBy(['shirt_size'])
->usingWhere([
'eventable_type' => \App\Models\StandaloneEvent::class,
'eventable_id' => $this->id,
])
->setTitle('Count by T-Shirt Sizes'),
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment