diff --git a/app/Http/Controllers/FlightController.php b/app/Http/Controllers/FlightController.php index 0c30237..9764077 100644 --- a/app/Http/Controllers/FlightController.php +++ b/app/Http/Controllers/FlightController.php @@ -8,14 +8,18 @@ use Illuminate\Http\Request; class FlightController extends Controller { - public function index() + public function index(Request $request) { - $flights =Flight::applySort() - ->where('status' , '=' , FlightStatus::AVAILABLE) - ->paginate() - ->withQueryString(); + $sort = $request->query('sort', 'default'); + + $flights = Flight::with(['airline', 'origin_airport', 'airport']) + ->where('status', '=', FlightStatus::AVAILABLE) + ->applySort($sort) + ->paginate(4) + ->appends(['sort' => $sort]); + $title = 'پروازها'; - return view('flights.index' , compact('title' , 'flights')); + return view('flights.index', compact('title', 'flights', 'sort')); } public function show(Flight $flight) diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 28db114..5cdad11 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -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; } } diff --git a/resources/views/flights/index.blade.php b/resources/views/flights/index.blade.php index d5c1deb..ff4a903 100644 --- a/resources/views/flights/index.blade.php +++ b/resources/views/flights/index.blade.php @@ -23,19 +23,22 @@
- +
- +
- + @@ -52,7 +55,8 @@
- +

فرودگاه بین المللی مشهد @@ -65,7 +69,8 @@

- +

فرودگاه بین المللی تهران

@@ -77,7 +82,8 @@
- +

@@ -85,7 +91,8 @@
- +

@@ -94,10 +101,13 @@
@@ -138,9 +156,13 @@

در زیر 2 سال

- - - + + +
@@ -148,20 +170,29 @@
کلاس کابین
- -
- -
- -
@@ -180,7 +211,8 @@
- +

فرودگاه بین المللی مشهد @@ -193,7 +225,8 @@

- +

فرودگاه بین المللی تهران

@@ -205,7 +238,8 @@
- +

@@ -226,7 +260,9 @@
- +
@@ -246,123 +282,158 @@
-
2,000 نتیجه پیداشد
+
{{$flights->total()}} نتیجه پیداشد
- +
+ +
-
-
-
-
-
-
-
- -
-
دلتا
-
-
-
-
- + @forelse($flights as $flight) +
+
+
+
+
+
+
-
-
07:30
- JFK +
{{$flight->airline?->name}}
+
+
+
+
+ +
+
+
{{$flight->departure_time}}
+ {{$flight->origin_airport->city->name}} +
+
+
+
+
+
+
+ +
+
+
{{$flight->arrival_time}}
+ {{$flight->airport->city->name}} +
-
- بدون توقف -
-
-
-
- -
-
-
08:35
- LAX -
-
-
-
- 4 ساعت 05 دقیقه
-
-
-
- 5000 تومان - 4000 تومان +
+
+ {{number_format($flight->price)}} + تومان +
+ اکنون ثبت کن
- اکنون ثبت کن
-
-
-
-

قابل استرداد جزئی

- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
شرکت هواپیمایی دلتا
- SG 143 | AT7 -
-

( اقتصادی )

-
-
-
-
- +
+
+

قابل استرداد جزئی

+ +
+
+
+
+
+
+ +
+
+
+
+
+
-
-
07:30
-

شنبه, 22 مهر, 1402

- JFK +
+
شرکت + هواپیمایی {{$flight->airline?->name}}
+

+ باشه واسه بعد

-
- بدون توقف -
-
- 4 ساعت 05 دقیقه +
+
+
+ +
+
+
+ {{\Hekmatinasser\Verta\Verta::instance($flight->departure_time)->format('H:i')}} +
+

+ {{\Hekmatinasser\Verta\Verta::instance($flight->departure_time)->format('l, d F Y')}} +

+ {{$flight->origin_airport->city->name}} +
-
-
-
- +
+
-
-
08:35
-

شنبه, 25 مهر, 1402

- LAX +
+
+ +
+
+
+

+ {{\Hekmatinasser\Verta\Verta::instance($flight->arrival_time)->format('l, d F Y')}} +

+ {{$flight->airport->city->name}} +
@@ -370,80 +441,33 @@
-
-
-
- -
-
-
- - - - - - - - - - - -
پرواز هاکابینبررسی کنید
JFK - LAX7 کیلوگرم20 کیلوگرم
-
-
-
-
- - - - - - - - - - - - - - - - -
خلاصه کرایهکرایه پایهمالیات
بزرگسال x 15000 تومان1000 تومان
کودک x 13000 تومان1000 تومان
-
-
-
-
-
-
    -
  • - 1. بازپرداخت و تغییر تاریخ طبق سیاست های زیر انجام می شود. -
  • -
  • - 2. مبلغ بازپرداخت = هزینه بازپرداخت (طبق خط مشی خطوط هوایی + هزینه تسهیلات شیر تریپ). -
  • -
  • - 3. مبلغ تغییر تاریخ = هزینه تغییر تاریخ (طبق خط‌مشی خطوط هوایی + هزینه تسهیلات شیر تریپ). -
  • -
+
+
+
+
+
+ + + + + + + +
پرواز ها
{{$flight->origin_airport->city->name}} + - {{$flight->airport->city->name}}
-
-
-
مجموع (2 مسافر)
-
- 10000 تومان +
+
مجموع + (2 + مسافر)
+
+ 10000 تومان +
@@ -452,33 +476,21 @@
-
+ @empty +
هیچ پروازی یافت نشد
+ @endforelse
- -
- + {{ $flights->links() }}
-

نمایش 1 - 6 از 24 پرواز

+

+ نمایش {{ $flights->firstItem() }} - {{ $flights->lastItem() }} + از {{ $flights->total() }} پرواز +

-