Add more airlines and fix edit bugs
This commit is contained in:
@@ -10,8 +10,7 @@ use Inertia\Inertia;
|
||||
|
||||
class FlightProfileController extends Controller
|
||||
{
|
||||
public function view(string $username)
|
||||
{
|
||||
public function profileData(string $username, string $view) : array {
|
||||
$user = User::whereRaw(DB::raw('LOWER(name) = ?'), [strtolower($username)])->firstOrFail();
|
||||
|
||||
$flights = UserFlight::where('user_id', $user->id)
|
||||
@@ -29,10 +28,31 @@ class FlightProfileController extends Controller
|
||||
->orderBy('departure_date', 'desc')
|
||||
->get();
|
||||
|
||||
return Inertia::render('FlightProfile', [
|
||||
return [
|
||||
'user' => $user,
|
||||
'canEdit' => auth()->check() && auth()->id() === $user->id,
|
||||
'flights' => UserFlightResource::collection($flights)->resolve(),
|
||||
]);
|
||||
'initialView' => $view,
|
||||
];
|
||||
}
|
||||
|
||||
public function departureBoard(string $username){
|
||||
$profileData = $this->profileData($username, 'board');
|
||||
return Inertia::render('UserProfile', $profileData);
|
||||
}
|
||||
|
||||
public function map(string $username){
|
||||
$profileData = $this->profileData($username, 'map');
|
||||
return Inertia::render('UserProfile', $profileData);
|
||||
}
|
||||
|
||||
public function boardingPasses(string $username){
|
||||
$profileData = $this->profileData($username, 'passes');
|
||||
return Inertia::render('UserProfile', $profileData);
|
||||
}
|
||||
|
||||
public function view(string $username)
|
||||
{
|
||||
return $this->departureBoard($username);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user