public static function payloads($substatistic, $dynamicString) { if ($substatistic === 'Satellites Launched') { if ($dynamicString === 'satelliteCount') { return Cache::remember('stats:description:payloads:satellitesLaunched:satelliteCount', 60, function () { return Payload::whereHas('mission', function ($q) { $q->whereComplete(); })->count(); }); } } if ($substatistic === 'Heaviest Satellite') { if ($dynamicString === 'heaviestSatellite') { return Cache::remember('stats:description:payloads:heaviestSatellite:heaviestSatellite', 60, function () { return Payload::orderBy('mass', 'desc')->whereHas('mission', function ($q) { $q->whereComplete(); })->first()->name; }); } if ($dynamicString === 'heaviestOperator') { return Cache::remember('stats:description:payloads:heaviestSatellite:heaviestSatellite', 60, function () { return Payload::orderBy('mass', 'desc')->whereHas('mission', function ($q) { $q->whereComplete(); })->first()->operator; }); } } }
/** * @param $substatistic * @return int */ public static function payloads($substatistic) { if ($substatistic == 'Satellites Launched') { return Cache::remember('stats:payloads:satellitesLaunched', 60, function () { $payloads = Payload::whereHas('mission', function ($q) { $q->where('status', MissionStatus::Complete); })->get(); $stat[1] = $payloads->count(); $stat[0] = $payloads->filter(function ($payload) { return $payload->primary; })->count(); return $stat; }); } else { if ($substatistic == 'Total Mass') { return Cache::remember('stats:payloads:totalMass', 60, function () { return number_format(round(Payload::whereHas('mission', function ($q) { $q->whereComplete(); })->sum('mass'))); }); } else { if ($substatistic == 'Mass to GTO') { return Cache::remember('stats:payloads:massToGTO', 60, function () { return number_format(round(Payload::whereHas('mission', function ($q) { $q->whereComplete()->whereHas('destination', function ($q) { $q->whereIn('destination', [Destination::GeostationaryTransferOrbit, Destination::SupersynchronousGTO, Destination::SubsynchronousGTO]); }); })->sum('mass'))); }); } else { if ($substatistic == 'Heaviest Satellite') { return Cache::remember('stats:payloads:heaviestSatellite', 60, function () { return number_format(round(Payload::whereHas('mission', function ($q) { $q->whereComplete(); })->max('mass'))); }); } } } } }