Skip to content

Commit

Permalink
Update table filters
Browse files Browse the repository at this point in the history
  • Loading branch information
NuwanJ committed Oct 21, 2024
1 parent 94d5775 commit 4882bc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/Http/Livewire/Backend/CourseTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function query(): Builder
return Course::query()
->when($this->getFilter('academic_program'), fn($query, $type) => $query->where('academic_program', $type))
->when($this->getFilter('semester_id'), fn($query, $type) => $query->where('semester_id', $type))
->when($this->getFilter('version'), fn($query, $version) => $query->where('version', $version));;
->when($this->getFilter('version'), fn($query, $version) => $query->where('version', $version));
}

public function filters(): array
Expand Down Expand Up @@ -80,4 +80,4 @@ public function rowView(): string
{
return 'backend.courses.index-table-row';
}
}
}
12 changes: 11 additions & 1 deletion app/Http/Livewire/Backend/EventsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ public function query(): Builder
} elseif ($enabled === 0) {
$query->where('enabled', false);
}
})->orderBy('published_at', 'desc');
})
->when(
$this->getFilter('event_type') !== null,
function ($query) {
$eventType = $this->getFilter('event_type');
$query->where('event_type', 'LIKE', "%\"$eventType\"%");
}
)
->orderBy('published_at', 'desc');
}
public function toggleEnable($eventId)
{
Expand All @@ -78,6 +86,8 @@ public function filters(): array
1 => 'Upcoming',
0 => 'Past',
]),
'event_type' => Filter::make("Event Type")
->select(array_merge(['' => 'Any'], Event::eventTypeMap()))
];
}

Expand Down

0 comments on commit 4882bc7

Please sign in to comment.