sort by coursesEvents

This commit is contained in:
Benjamin Takats
2023-01-15 15:02:15 +01:00
parent bceae06176
commit 002879b375
3 changed files with 32 additions and 25 deletions

View File

@@ -30,6 +30,7 @@ class EventTable extends Component
'course',
'venue.city.country',
])
->where('from', '>=', now())
->where(fn($query) => $query
->whereHas('venue.city.country',
fn($query) => $query->where('countries.code', $this->country->code))
@@ -41,6 +42,7 @@ class EventTable extends Component
'coords' => [$event->venue->city->latitude, $event->venue->city->longitude],
]),
'events' => CourseEvent::query()
->where('from', '>=', now())
->get()
->map(fn($event) => [
'id' => $event->id,

View File

@@ -22,14 +22,18 @@ class LecturerLandingPage extends Component
{
return view('livewire.school.lecturer-landing-page', [
'courseEvents' => CourseEvent::query()
->where('from', '>=', now())
->whereHas('course', function ($query) {
$query->where('lecturer_id', $this->lecturer->id);
})
->orderBy('from')
->get(),
'events' => CourseEvent::query()
->where('from', '>=', now())
->whereHas('course', function ($query) {
$query->where('lecturer_id', $this->lecturer->id);
})
->orderBy('from')
->get()
->map(fn($event) => [
'id' => $event->id,

View File

@@ -166,6 +166,7 @@ class EventTable extends DataTableComponent
->withCount([
'registrations',
])
->where('from', '>=', now())
->whereHas('venue.city.country',
fn($query) => $query->where('countries.code', $this->country));
}