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(),
]);
}
}
@@ -24,6 +24,7 @@ class FlightProfileController extends Controller
'seatType',
'flightReason',
'flightClass',
'crewType'
])
->orderBy('departure_date', 'desc')
->get();
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CrewType extends Model
{
protected $table = 'crew_types';
protected $fillable = [
'name',
'internal_name',
];
}
+4 -1
View File
@@ -6,5 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class FlightClass extends Model
{
//
protected $fillable = [
'name',
'internal_name',
];
}
+7
View File
@@ -23,6 +23,7 @@ class UserFlight extends Model
'seat_type_id',
'flight_class_id',
'flight_reason_id',
'crew_type_id',
'note',
'auto_update',
];
@@ -66,11 +67,17 @@ class UserFlight extends Model
return $this->belongsTo(Airport::class, 'arrival_airport_id');
}
public function crewType(): BelongsTo
{
return $this->belongsTo(CrewType::class);
}
public function airline(): BelongsTo
{
return $this->belongsTo(Airline::class);
}
public function aircraft(): BelongsTo
{
return $this->belongsTo(Aircraft::class);