35 lines
861 B
PHP
35 lines
861 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\User;
|
|
use App\Models\UserFlight;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Inertia\Inertia;
|
|
|
|
class FlightProfileController extends Controller
|
|
{
|
|
public function view(string $username)
|
|
{
|
|
$user = User::whereRaw(DB::raw('LOWER(name) = ?'), [strtolower($username)])->firstOrFail();
|
|
|
|
$flights = UserFlight::where('user_id', $user->id)
|
|
->with([
|
|
'departureAirport',
|
|
'arrivalAirport',
|
|
'airline.country',
|
|
'aircraft',
|
|
'seatType',
|
|
'flightReason',
|
|
'flightClass',
|
|
])
|
|
->orderBy('departure_date')
|
|
->get();
|
|
|
|
return Inertia::render('FlightProfile', [
|
|
'user' => $user,
|
|
'flights' => $flights,
|
|
]);
|
|
}
|
|
}
|