From 3e60fa13d3a6491572c44f84c68bc7b4fc48d666 Mon Sep 17 00:00:00 2001 From: mina-esn Date: Thu, 20 Aug 2026 13:31:51 +0330 Subject: [PATCH] feat: implement flights index and blade view for panel admin --- app/Enums/Flight/FlightStatus.php | 10 + .../Controllers/Admin/FlightController.php | 58 +++- app/Models/Flight.php | 2 +- resources/views/admin/flights/index.blade.php | 264 +++++++++++++++++ .../f15bec3b6182a4faac2a96175f00fd64.php | 277 ++++++++++++++++++ 5 files changed, 609 insertions(+), 2 deletions(-) create mode 100644 resources/views/admin/flights/index.blade.php create mode 100644 storage/framework/views/f15bec3b6182a4faac2a96175f00fd64.php diff --git a/app/Enums/Flight/FlightStatus.php b/app/Enums/Flight/FlightStatus.php index 10ff780..05ec277 100644 --- a/app/Enums/Flight/FlightStatus.php +++ b/app/Enums/Flight/FlightStatus.php @@ -10,4 +10,14 @@ enum FlightStatus:int case CANCELLED = 2; case DRAFT = 3; case DELAYED = 4; + public function label(): string + { + return match($this) { + self::AVAILABLE => 'در دسترس', + self::FULL => 'تکمیل ظرفیت', + self::CANCELLED => 'کنسل شده', + self::DRAFT => 'در انتظار', + self::DELAYED => 'با تاخیر', + }; + } } diff --git a/app/Http/Controllers/Admin/FlightController.php b/app/Http/Controllers/Admin/FlightController.php index 3466eea..1cf6401 100644 --- a/app/Http/Controllers/Admin/FlightController.php +++ b/app/Http/Controllers/Admin/FlightController.php @@ -3,9 +3,65 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Models\Flight; use Illuminate\Http\Request; class FlightController extends Controller { - // + public function index(Request $request) + { + $flights = Flight::query() + ->with([ + 'airline', + 'origin_airport.city', + 'airport.city', + 'coverImage.file', + ]) + ->when($request->filled('search'), function ($query) use ($request) { + $search = $request->input('search'); + + $query->whereAny([ + 'flight_number', + '' + ], 'like', "%{$search}%"); + }) + ->applySort($request->input('sort')) + ->paginate(10) + ->withQueryString(); + + return view('admin.flights.index', compact('flights')); + } + + public function create() + { + + } + + public function store() + { + + } + + public function edit() + { + + } + + public function update() + { + + } + + public function destroy() + { + + } + public function restore() + { + + } + public function forceDelete() + { + + } } diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 399a70f..575b201 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -81,7 +81,7 @@ class Flight extends Model { switch ($sort) { case 'popularity': - $query->withCount('bookings')->orderByDesc('bookings_count'); + $query->orderByDesc('views_count'); break; case 'lowest': diff --git a/resources/views/admin/flights/index.blade.php b/resources/views/admin/flights/index.blade.php new file mode 100644 index 0000000..5094f39 --- /dev/null +++ b/resources/views/admin/flights/index.blade.php @@ -0,0 +1,264 @@ +@extends('admin.layouts.app') + +@section('breadcrumb') +
+

لیست پروازها

+ + +
+@endsection + +@section('content') +
+ + @if(session('success')) +
+ {{ session('success') }} +
+ @endif + + @if(session('error')) +
+ {{ session('error') }} +
+ @endif + +
+
+
+
+
+
+ +
+
+ + + +
+ + +
+ + + +
+
+
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + @forelse($flights as $flight) + + + + + + + + + + + + + + + + + + + + + + + + + + @empty + + + + @endforelse + +
تصویرشماره پروازایرلاینمبدأمقصدزمان حرکتقیمتظرفیتوضعیتبازدیدتاریخ ایجاداقدامات
+ + @if($flight->coverImage?->file_id) + {{ $flight->flight_number }} + @else + - + @endif + + + + {{ $flight->flight_number }} + + + {{ $flight->airline?->name ?? '-' }} + +
+ {{ $flight->origin_airport?->city?->name ?? '-' }} +
+ + @if($flight->origin_airport?->name) + + {{ $flight->origin_airport->name }} + + @endif +
+
+ {{ $flight->airport?->city?->name ?? '-' }} +
+ + @if($flight->airport?->name) + + {{ $flight->airport->name }} + + @endif +
+ @if($flight->departure_time) + {{ \Hekmatinasser\Verta\Verta::instance($flight->departure_time)->format('d F Y - H:i') }} + @else + - + @endif + + {{ number_format($flight->price) }} تومان + + + {{ $flight->capacity }} نفر + + + @if($flight->status) + + {{ $flight->status->label() }} + + @else + - + @endif + + {{ number_format($flight->views_count ?? 0) }} + + @if($flight->created_at) + {{ \Hekmatinasser\Verta\Verta::instance($flight->created_at)->format('d F Y - H:i') }} + @else + - + @endif + +
+ + + + + + + + +
+ @csrf + @method('DELETE') + + +
+
+
+ هیچ پروازی یافت نشد. +
+
+
+
+
+ +
+ {{ $flights->links() }} +
+ +
+@endsection diff --git a/storage/framework/views/f15bec3b6182a4faac2a96175f00fd64.php b/storage/framework/views/f15bec3b6182a4faac2a96175f00fd64.php new file mode 100644 index 0000000..7379850 --- /dev/null +++ b/storage/framework/views/f15bec3b6182a4faac2a96175f00fd64.php @@ -0,0 +1,277 @@ +startSection('breadcrumb'); ?> +
+

لیست پروازها

+ + +
+stopSection(); ?> + +startSection('content'); ?> +
+ + +
+ + +
+ + + +
+ + +
+ + +
+
+
+
+
+
+ +
+
+ + + +
+ + +
+ + + +
+
+
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + addLoop($__currentLoopData); foreach($__currentLoopData as $flight): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?> + + + + + + + + + + + + + + + + + + + + + + + + + + popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?> + + + + + +
تصویرشماره پروازایرلاینمبدأمقصدزمان حرکتقیمتظرفیتوضعیتبازدیدتاریخ ایجاداقدامات
+ + coverImage?->file_id): ?> + <?php echo e($flight->flight_number); ?> + + - + + + + + flight_number); ?> + + + + airline?->name ?? '-'); ?> + + +
+ origin_airport?->city?->name ?? '-'); ?> + +
+ + origin_airport?->name): ?> + + origin_airport->name); ?> + + + +
+
+ airport?->city?->name ?? '-'); ?> + +
+ + airport?->name): ?> + + airport->name); ?> + + + +
+ departure_time): ?> + departure_time)->format('d F Y - H:i')); ?> + + + - + + + price)); ?> تومان + + + capacity); ?> نفر + + + status): ?> + + status->label()); ?> + + + + - + + + views_count ?? 0)); ?> + + + created_at): ?> + created_at)->format('d F Y - H:i')); ?> + + + - + + +
+ + + + + + + + +
+ + + + +
+
+
+ هیچ پروازی یافت نشد. +
+
+
+
+
+ +
+ links()); ?> + +
+ +
+stopSection(); ?> + +make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?> \ No newline at end of file