Added Crew and General Aviation Filters

This commit is contained in:
2026-04-20 22:30:34 +10:00
parent e007824fa9
commit a57775e141
26 changed files with 559 additions and 98 deletions
+13 -6
View File
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Airline;
use App\Models\Airport;
use App\Models\CrewType;
use App\Models\FlightClass;
use App\Models\FlightReason;
use App\Models\SeatType;
@@ -33,6 +34,7 @@ class FlightController extends Controller
'flight_reason_id' => ['integer', 'exists:flight_reasons,id'],
'note' => ['nullable', 'string', 'max:5000'],
'auto_update' => ['boolean'],
'crew_type_id' => ['nullable', 'exists:crew_types,id'],
];
}
@@ -88,6 +90,7 @@ class FlightController extends Controller
'flight_reason_id' => $validated['flight_reason_id'],
'note' => $validated['note'],
'auto_update' => $validated['auto_update'],
'crew_type_id' => $validated['crew_type_id'],
];
}
@@ -113,12 +116,17 @@ class FlightController extends Controller
return redirect()->route('profile.departure-board', [Auth::user()->name, $flight->id]);
}
public function add(){
return Inertia::render('AddFlight', [
public function staticData() : array {
return [
'seat_types' => SeatType::orderBy('id')->get()->toArray(),
'flight_reasons' => FlightReason::orderBy('id')->get()->toArray(),
'flight_classes' => FlightClass::orderBy('id')->get()->toArray(),
]);
'crew_types' => CrewType::orderBy('id')->get()->toArray(),
];
}
public function add(){
return Inertia::render('AddFlight', $this->staticData());
}
public function edit(UserFlight $flight)
@@ -136,6 +144,7 @@ class FlightController extends Controller
'auto_update' => $flight->auto_update,
'seat_type' => $flight->seatType->toArray(),
'flight_class' => $flight->flightClass->toArray(),
'crew_type' => $flight->crewType?->toArray() ?? [],
'flight_reason' => $flight->flightReason->toArray(),
'airline_options' => $flight->airline
? [['value' => $flight->airline->id, 'title' => $flight->airline->display_name]]
@@ -148,9 +157,7 @@ class FlightController extends Controller
];
return Inertia::render('AddFlight', [
'flight' => $flightData,
'seat_types' => SeatType::orderBy('id')->get()->toArray(),
'flight_reasons' => FlightReason::orderBy('id')->get()->toArray(),
'flight_classes' => FlightClass::orderBy('id')->get()->toArray(),
...$this->staticData(),
]);
}
}