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') +
| تصویر | +شماره پرواز | +ایرلاین | +مبدأ | +مقصد | +زمان حرکت | +قیمت | +ظرفیت | +وضعیت | +بازدید | +تاریخ ایجاد | +اقدامات | +
|---|---|---|---|---|---|---|---|---|---|---|---|
|
+
+ @if($flight->coverImage?->file_id)
+ |
+
+ + + {{ $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 + | + ++ + | +
| + هیچ پروازی یافت نشد. + | +|||||||||||
| تصویر | +شماره پرواز | +ایرلاین | +مبدأ | +مقصد | +زمان حرکت | +قیمت | +ظرفیت | +وضعیت | +بازدید | +تاریخ ایجاد | +اقدامات | +
|---|---|---|---|---|---|---|---|---|---|---|---|
|
+
+ coverImage?->file_id): ?>
+ |
+
+ + + 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')); ?> + + + - + + | + ++ + | +
| + هیچ پروازی یافت نشد. + | +|||||||||||