Added achievement data
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class AdminToolsController extends Controller
|
||||||
|
{
|
||||||
|
function missingLiveries(){
|
||||||
|
|
||||||
|
|
||||||
|
/* $existingFiles = collect(glob(public_path('img/liveries/generated/*')))
|
||||||
|
->map(fn ($path) => pathinfo($path, PATHINFO_FILENAME))
|
||||||
|
->toArray();*/
|
||||||
|
|
||||||
|
$existingFiles = collect(glob('C:\\Users\\josh\\WebstormProjects\\Watermark-Remover\\images\\liveries_processed\\*'))
|
||||||
|
->map(fn ($path) => pathinfo($path, PATHINFO_FILENAME))
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
|
||||||
|
$combos = \App\Models\UserFlight::with(['aircraft', 'airline'])
|
||||||
|
->select('airline_id', 'aircraft_id')
|
||||||
|
->whereNotNull('airline_id')
|
||||||
|
->whereNotNull('aircraft_id')
|
||||||
|
->distinct()
|
||||||
|
->get()
|
||||||
|
->filter(fn ($flight) => $flight->aircraft && $flight->airline)
|
||||||
|
->map(fn ($flight) => [
|
||||||
|
'airline_name' => $flight->airline->name,
|
||||||
|
'aircraft_display_name' => $flight->aircraft->display_name,
|
||||||
|
'filename' => $flight->airline->internal_name . '_' . $flight->aircraft->designator,
|
||||||
|
])
|
||||||
|
->filter(fn ($combo) => !in_array($combo['filename'], $existingFiles))
|
||||||
|
->values();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'count' => $combos->count(),
|
||||||
|
'liveries' => $combos,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,4 +40,19 @@ class FlightProfileController extends Controller
|
|||||||
{
|
{
|
||||||
return $this->departureBoard($user);
|
return $this->departureBoard($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function flight(User $user, UserFlight $userFlight)
|
||||||
|
{
|
||||||
|
if($userFlight->user_id !== $user->id){
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return Inertia::render('UserFlight', [
|
||||||
|
'flightCount' => $user->flights()->count(),
|
||||||
|
'flight' => $userFlight->snapshot($userFlight->id),
|
||||||
|
'user' => $user,
|
||||||
|
'isFollowing' => auth()->check() && auth()->user()->isFollowing($user),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class UserFlight extends Model
|
|||||||
'duration',
|
'duration',
|
||||||
'duration_display',
|
'duration_display',
|
||||||
'distance',
|
'distance',
|
||||||
|
'livery_url',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function calculateGreatCircleDistance(): float{
|
public function calculateGreatCircleDistance(): float{
|
||||||
@@ -156,7 +157,8 @@ class UserFlight extends Model
|
|||||||
return !$this->isDomestic();
|
return !$this->isDomestic();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function snapshot($userFlightId){
|
public static function snapshot($userFlightId): array
|
||||||
|
{
|
||||||
return UserFlight::with([
|
return UserFlight::with([
|
||||||
'departureAirport',
|
'departureAirport',
|
||||||
'departureAirport.region.country',
|
'departureAirport.region.country',
|
||||||
@@ -218,4 +220,21 @@ class UserFlight extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(FlightReason::class);
|
return $this->belongsTo(FlightReason::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function liveryUrl(): Attribute{
|
||||||
|
return Attribute::make(
|
||||||
|
get: function () {
|
||||||
|
if($this->airline) {
|
||||||
|
$fileName = "{$this->airline->internal_name}_{$this->aircraft->designator}.png";
|
||||||
|
$file = public_path("img/liveries/generated/$fileName");
|
||||||
|
|
||||||
|
if (file_exists($file)) {
|
||||||
|
return "/img/liveries/generated/$fileName";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 250 KiB |
|
After Width: | Height: | Size: 504 KiB |
|
After Width: | Height: | Size: 550 KiB |
|
After Width: | Height: | Size: 560 KiB |
|
After Width: | Height: | Size: 564 KiB |
|
After Width: | Height: | Size: 572 KiB |
|
After Width: | Height: | Size: 486 KiB |
|
After Width: | Height: | Size: 615 KiB |
|
After Width: | Height: | Size: 639 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 524 KiB |
|
After Width: | Height: | Size: 528 KiB |
|
After Width: | Height: | Size: 494 KiB |
|
After Width: | Height: | Size: 504 KiB |
|
After Width: | Height: | Size: 422 KiB |
|
After Width: | Height: | Size: 563 KiB |
|
After Width: | Height: | Size: 487 KiB |
|
After Width: | Height: | Size: 464 KiB |
|
After Width: | Height: | Size: 551 KiB |
|
After Width: | Height: | Size: 543 KiB |
|
After Width: | Height: | Size: 524 KiB |
|
After Width: | Height: | Size: 554 KiB |
|
After Width: | Height: | Size: 628 KiB |
|
After Width: | Height: | Size: 578 KiB |
|
After Width: | Height: | Size: 503 KiB |
|
After Width: | Height: | Size: 471 KiB |
|
After Width: | Height: | Size: 535 KiB |
|
After Width: | Height: | Size: 557 KiB |
|
After Width: | Height: | Size: 537 KiB |
|
After Width: | Height: | Size: 573 KiB |
|
After Width: | Height: | Size: 526 KiB |
|
After Width: | Height: | Size: 555 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 367 KiB |
|
After Width: | Height: | Size: 498 KiB |
|
After Width: | Height: | Size: 412 KiB |
|
After Width: | Height: | Size: 566 KiB |
|
After Width: | Height: | Size: 558 KiB |
|
After Width: | Height: | Size: 560 KiB |
|
After Width: | Height: | Size: 483 KiB |
|
After Width: | Height: | Size: 455 KiB |
|
After Width: | Height: | Size: 553 KiB |
|
After Width: | Height: | Size: 630 KiB |
|
After Width: | Height: | Size: 538 KiB |
|
After Width: | Height: | Size: 454 KiB |
|
After Width: | Height: | Size: 354 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 403 KiB |
|
After Width: | Height: | Size: 532 KiB |
|
After Width: | Height: | Size: 500 KiB |
|
After Width: | Height: | Size: 522 KiB |
|
After Width: | Height: | Size: 508 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 496 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 462 KiB |
|
After Width: | Height: | Size: 515 KiB |
|
After Width: | Height: | Size: 522 KiB |
|
After Width: | Height: | Size: 403 KiB |
|
After Width: | Height: | Size: 513 KiB |
|
After Width: | Height: | Size: 506 KiB |
|
After Width: | Height: | Size: 515 KiB |
|
After Width: | Height: | Size: 361 KiB |
|
After Width: | Height: | Size: 668 KiB |
|
After Width: | Height: | Size: 509 KiB |
|
After Width: | Height: | Size: 606 KiB |
|
After Width: | Height: | Size: 473 KiB |
|
After Width: | Height: | Size: 667 KiB |
|
After Width: | Height: | Size: 541 KiB |
|
After Width: | Height: | Size: 538 KiB |
|
After Width: | Height: | Size: 516 KiB |
|
After Width: | Height: | Size: 597 KiB |
|
After Width: | Height: | Size: 543 KiB |
|
After Width: | Height: | Size: 520 KiB |
|
After Width: | Height: | Size: 504 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 459 KiB |
|
After Width: | Height: | Size: 395 KiB |
|
After Width: | Height: | Size: 246 KiB |
|
After Width: | Height: | Size: 582 KiB |
|
After Width: | Height: | Size: 547 KiB |
|
After Width: | Height: | Size: 419 KiB |
|
After Width: | Height: | Size: 575 KiB |
|
After Width: | Height: | Size: 486 KiB |
|
After Width: | Height: | Size: 562 KiB |
|
After Width: | Height: | Size: 552 KiB |
|
After Width: | Height: | Size: 518 KiB |
|
After Width: | Height: | Size: 473 KiB |
|
After Width: | Height: | Size: 660 KiB |
|
After Width: | Height: | Size: 253 KiB |
|
After Width: | Height: | Size: 637 KiB |
|
After Width: | Height: | Size: 615 KiB |
|
After Width: | Height: | Size: 246 KiB |
|
After Width: | Height: | Size: 570 KiB |
|
After Width: | Height: | Size: 580 KiB |
|
After Width: | Height: | Size: 431 KiB |
|
After Width: | Height: | Size: 550 KiB |