Untitled

 avatar
unknown
php
2 years ago
934 B
6
Indexable
$tireLaps = Lap::join('track_variations', 'track_variation_id', 'track_variations.id')
            ->leftJoin('vi', 'vi_id', 'vi.id')
            ->join('vehicle_years', 'vehicle_years.id', 'laps.vehicle_year_id')
            ->join('vehicles', 'vehicles.id', 'vehicle_years.vehicle_id')
            ->where('length', '>', 0)
            ->where('track_variations.flagged', 0)
            ->where('wet', 0)
            ->where('novice', 0)
            ->where('laps.flagged', 0)
            ->select(
                DB::raw('IFNULL(vi.tire_id_front, vehicles.tire_id_front) as tire_id'),
                DB::raw('IFNULL(vi.size_id_front, vehicles.size_id_front) as size_front_id'),
                DB::raw('IFNULL(vi.size_id_rear, vehicles.size_id_rear) as size_rear_id'),
                "vehicles.id as vehicle_id",
                DB::raw('avg((track_variations.length/time_ms) / estimated_speed_avg) as speed_avg')
            );
Editor is loading...