feat: implement flights index and blade view for panel admin

This commit is contained in:
2026-08-20 13:31:51 +03:30
parent 8d0cd16384
commit 3e60fa13d3
5 changed files with 609 additions and 2 deletions
+10
View File
@@ -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 => 'با تاخیر',
};
}
}
@@ -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()
{
}
}
+1 -1
View File
@@ -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':