Added achievement data
This commit is contained in:
@@ -45,6 +45,7 @@ class UserFlight extends Model
|
||||
'duration',
|
||||
'duration_display',
|
||||
'distance',
|
||||
'livery_url',
|
||||
];
|
||||
|
||||
public function calculateGreatCircleDistance(): float{
|
||||
@@ -156,7 +157,8 @@ class UserFlight extends Model
|
||||
return !$this->isDomestic();
|
||||
}
|
||||
|
||||
public static function snapshot($userFlightId){
|
||||
public static function snapshot($userFlightId): array
|
||||
{
|
||||
return UserFlight::with([
|
||||
'departureAirport',
|
||||
'departureAirport.region.country',
|
||||
@@ -218,4 +220,21 @@ class UserFlight extends Model
|
||||
{
|
||||
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;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user