table counts added

This commit is contained in:
Benjamin Takats
2022-12-01 22:42:49 +01:00
parent ff498d2c5b
commit b658e5e66e
7 changed files with 43 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ class CourseTable extends DataTableComponent
->sortable(),
Column::make("Termine")
->label(
fn($row, Column $column) => '<strong>'.$row->events->count().'</strong>'
fn($row, Column $column) => '<strong>'.$row->events_count.'</strong>'
)
->html()
->sortable(),
@@ -43,6 +43,9 @@ class CourseTable extends DataTableComponent
public function builder(): Builder
{
return Course::query()
->withCount([
'events',
])
->whereHas('events.venue.city.country',
fn($query) => $query->where('countries.code', $this->country));
}