v1 Release

This commit is contained in:
2026-07-11 18:44:40 +10:00
parent 85eeba982f
commit 5ac580bb06
15 changed files with 171 additions and 72 deletions
@@ -129,10 +129,12 @@ class GetAircraftInfoForArrivedFlights extends Command
if ($data->estimated_departure_utc?->ne($originalDeparture)) {
$updates['departure_date'] = $data->estimated_departure_utc;
$updates['departure_processed_at'] = $data->estimated_departure_utc;
}
if ($data->estimated_arrival_utc?->ne($originalArrival)) {
$updates['arrival_date'] = $data->estimated_arrival_utc;
$updates['arrival_processed_at'] = $data->estimated_arrival_utc;
}
if ($data->equipment_iata && $originalAircraft?->iata_code !== $data->equipment_iata) {
@@ -93,7 +93,6 @@ class UserProfileController extends Controller
'canView' => Gate::allows('viewProfileData', $user),
'user' => $user,
'followStatus' => auth()->check() ? auth()->user()->followStatus($user) : 'none',
'otherUsersOnFlight' => $userFlight->otherUsersOnFlight(),
]);
}
+34 -17
View File
@@ -55,11 +55,12 @@ class UserFlight extends Model
'duration',
'duration_display',
'distance',
'livery_url',
'livery',
'scope',
'range',
'region_range',
'class_seat_combined'
'class_seat_combined',
'other_users_on_flight'
];
protected static function booted(): void
@@ -207,19 +208,23 @@ class UserFlight extends Model
return !$this->isDomestic();
}
public function otherUsersOnFlight(): Collection
protected function otherUsersOnFlight(): Attribute
{
return UserFlight::where('user_id', '!=', $this->user_id)
->where('departure_airport_id', $this->departure_airport_id)
->where('arrival_airport_id', $this->arrival_airport_id)
->where('flight_number', $this->flight_number)
->where('airline_id', $this->airline_id)
->whereRaw('DATE(departure_date AT TIME ZONE \'UTC\') = ?', [
Carbon::parse($this->departure_date)->utc()->toDateString()
])
->with('user')
->get()
->pluck('user.name');
return Attribute::make(
get: function () {
return once(fn() => UserFlight::where('user_id', '!=', $this->user_id)
->where('departure_airport_id', $this->departure_airport_id)
->where('arrival_airport_id', $this->arrival_airport_id)
->where('flight_number', $this->flight_number)
->where('airline_id', $this->airline_id)
->whereRaw('DATE(departure_date AT TIME ZONE \'UTC\') = ?', [
Carbon::parse($this->departure_date)->utc()->toDateString()
])
->with('user')
->get()
->pluck('user.name'));
}
);
}
public static function snapshot($userFlightId): array
@@ -286,16 +291,19 @@ class UserFlight extends Model
return $this->belongsTo(FlightReason::class);
}
public function liveryUrl(): Attribute{
public function livery(): Attribute{
return Attribute::make(
get: function () {
$user = auth()?->user();
$useAi = !$user || $user->getSetting('ai_liveries');
$apiUrl = config('app.logo_api_url');
$attribution = '';
$attributionUrl = '';
$isAi = false;
if (!$this->aircraft) {
return null;
}
@@ -305,6 +313,8 @@ class UserFlight extends Model
$path = "images/liveries/{$this->airline->internal_name}_{$this->aircraft->designator}.png";
if (Storage::disk('local')->exists($path)) {
$finalPath = $apiUrl."/airline/{$this->airline->internal_name}/livery/{$this->aircraft->designator}";
$attribution = 'This image is AI generated and may not be an accurate representation of the aircraft.';
$isAi = true;
}
}
@@ -312,6 +322,8 @@ class UserFlight extends Model
$path = "images/livery_templates/{$this->aircraft->designator}.png";
if (Storage::disk('local')->exists($path)) {
$finalPath = $apiUrl."/aircraft/{$this->aircraft->designator}/livery";
$attribution = '© NoRebbo Blank Aircraft Templates';
$attributionUrl = 'https://www.norebbo.com/category/aircraft-templates/';
}
}
@@ -319,7 +331,12 @@ class UserFlight extends Model
return null;
}
return $finalPath;
return [
'image_url' => $finalPath,
'attribution' => $attribution,
'attribution_url' => $attributionUrl,
'is_ai' => $isAi,
];
}
);
}