From 9e757ba8ed7660b571d16ea4a36d7ea8f0bdb055 Mon Sep 17 00:00:00 2001 From: Windows Store Date: Mon, 17 Aug 2026 15:53:14 +0330 Subject: [PATCH] feat(flights): add flight listing page --- app/Http/Controllers/FlightController.php | 38 ++++ bootstrap/app.php | 1 + .../views/components/flightcard.blade.php | 27 +-- resources/views/flights/index.blade.php | 180 ++++++++++++++++++ 4 files changed, 235 insertions(+), 11 deletions(-) create mode 100644 app/Http/Controllers/FlightController.php create mode 100644 resources/views/flights/index.blade.php diff --git a/app/Http/Controllers/FlightController.php b/app/Http/Controllers/FlightController.php new file mode 100644 index 0000000..bbd7792 --- /dev/null +++ b/app/Http/Controllers/FlightController.php @@ -0,0 +1,38 @@ +with(['airline', 'airport', 'destinationAirport']) + ->latest() + ->paginate(2) + ->appends($request->query()); + + $flights->each(function ($flight) { + $minutes = Carbon::parse($flight->start_time)->diffInMinutes(Carbon::parse($flight->end_time)); + + $flight->duration_hours = intdiv($minutes, 60); + $flight->duration_minutes = $minutes % 60; + + $flight->start_time_fa = verta($flight->start_time)->format('%H:%M'); + $flight->end_time_fa = verta($flight->end_time)->format('%H:%M'); + $flight->full_date_fa = verta($flight->start_time)->format('%A, %d %B, %Y'); + $flight->end_date_fa = verta($flight->end_time)->format('%A, %d %B, %Y'); + }); + + return view('flights.index', compact('flights')); + } + + public function show() + { + + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index 6fe309a..f7a6ae4 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -9,6 +9,7 @@ return Application::configure(basePath: dirname(__DIR__)) web: [ __DIR__.'/../routes/web.php', __DIR__.'/../routes/auth.php', + __DIR__.'/../routes/dashboard.php', ], commands: __DIR__.'/../routes/console.php', health: '/up', diff --git a/resources/views/components/flightcard.blade.php b/resources/views/components/flightcard.blade.php index bf16136..a3904af 100644 --- a/resources/views/components/flightcard.blade.php +++ b/resources/views/components/flightcard.blade.php @@ -1,32 +1,37 @@
-
- - + {{ $card->flight_number }} +
-

{{$card->title}}

{{$card->tour_type}} -
- - {{ $card->originAirport->city }} -> {{ $card->destinationAirport->city }} +

+ شماره پرواز: {{ $card->flight_number }} +

+ {{ $card->airline->name ?? '' }} +
+ + {{ $card->airport->city ?? '' }} -> {{ $card->destinationAirport->city ?? '' }} + + + {{ $card->start_date_fa }} +
+
- {{ number_format($card->tour_details->first()?->price) }} تومان + {{ number_format($card->price) }} تومان
-
diff --git a/resources/views/flights/index.blade.php b/resources/views/flights/index.blade.php new file mode 100644 index 0000000..9479a00 --- /dev/null +++ b/resources/views/flights/index.blade.php @@ -0,0 +1,180 @@ +@extends('layouts.app') + +@section('content') +
+ + + + + +
+
+
+ + +
+ + @forelse($flights as $flight) +
+
+
+
+
+
+
+ {{ $flight->airline->name ?? '' }} +
+
{{ $flight->airline->name ?? '' }}
+
+
+
+
+ +
+
+
{{ $flight->start_time_fa }}
+ {{ $flight->airport->city ?? '' }} +
+
+
+ بدون توقف +
+
+
+
+ +
+
+
{{ $flight->end_time_fa }}
+ {{ $flight->destinationAirport->city ?? '' }} +
+
+
+
+ + {{ $flight->duration_hours }} ساعت + @if($flight->duration_minutes != 0) + {{ $flight->duration_minutes }}دقیقه + @else + + @endif + + +
+
+
+
+
+ {{ number_format($flight->price) }} تومان +
+ اکنون ثبت کن +
+
+
+
+

ظرفیت باقی‌مانده: {{ $flight->capacity }} صندلی

+ +
+
+
+
+
+
+ +
+
+
+
+
+ {{ $flight->airline->name ?? '' }} +
+
+
{{ $flight->airline->name ?? '' }}
+ {{ $flight->flight_number }} +
+
+
+
+
+ +
+
+
{{ $flight->start_time_fa }}
+

{{ $flight->full_date_fa }}

+ {{ $flight->airport->city ?? '' }} +
+
+
+ بدون توقف +
+
+ {{ $flight->duration_hours }} ساعت {{ $flight->duration_minutes }} دقیقه +
+
+
+
{{ $flight->end_time_fa }}
+

{{ $flight->end_date_fa }}

+ {{ $flight->destinationAirport->city ?? '' }} +
+
+
+
+
+
+
+
+
+
+
قیمت هر صندلی
+
+ {{ number_format($flight->price) }} تومان +
+
+
+
+
+
+
+
+
+
+ @empty +
+

پروازی یافت نشد.

+
+ @endforelse + +
+
+ {{ $flights->links() }} +
+
+

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

+
+
+ +
+
+
+
+
+ + + +@endsection