fix: fix flight list and make it dynamic
This commit is contained in:
@@ -68,12 +68,11 @@ class Flight extends Model
|
||||
'trip_type'
|
||||
];
|
||||
#[Scope]
|
||||
protected function applySort(Builder $query): void
|
||||
protected function applySort(Builder $query, ?string $sort = null): void
|
||||
{
|
||||
switch (request()->input('sort')) {
|
||||
switch ($sort) {
|
||||
case 'popularity':
|
||||
$query->withCount('bookings')
|
||||
->orderByDesc('bookings_count');
|
||||
$query->withCount('bookings')->orderByDesc('bookings_count');
|
||||
break;
|
||||
|
||||
case 'lowest':
|
||||
@@ -85,7 +84,7 @@ class Flight extends Model
|
||||
break;
|
||||
|
||||
default:
|
||||
$query->latest('id'); // همهی پروازها
|
||||
$query->orderByDesc('id');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user