diff --git a/app/Controllers/Races.php b/app/Controllers/Races.php index 18df86a..41f4ee5 100644 --- a/app/Controllers/Races.php +++ b/app/Controllers/Races.php @@ -29,15 +29,19 @@ class Races extends BaseController $builder = $this->db->table('laps'); $builder->where('race_id', $tplData['race']->id); $query = $builder->get(); - + + $tplData['race']->n_laps = 0; if ($query && $query->getNumRows() > 0) { $tplData['laps'] = json_encode($query->getResult()); - $tplData['user'] = new UsersModel($tplData['race']->user_id); - $tplData['car'] = new CarsModel(getCar($tplData['race']->car_id)); - $tplData['track'] = new TracksModel(getTrack($tplData['race']->track_id)); + $tplData['race']->n_laps = $query->getNumRows(); } + + $tplData['user'] = new UsersModel($tplData['race']->user_id); + $tplData['car'] = new CarsModel(getCar($tplData['race']->car_id)); + $tplData['track'] = new TracksModel(getTrack($tplData['race']->track_id)); } + echo get_header('Races'); echo view('race', $tplData); echo get_footer(['chart.min.js']); diff --git a/app/Views/race.php b/app/Views/race.php index 7a76fbd..e154937 100644 --- a/app/Views/race.php +++ b/app/Views/race.php @@ -30,11 +30,18 @@ = $user->getLink() ?> +