Fix error if no laps
This commit is contained in:
parent
4f4138e073
commit
c3eff73ecc
|
@ -30,14 +30,18 @@ class Races extends BaseController
|
|||
$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']);
|
||||
|
|
|
@ -30,11 +30,18 @@
|
|||
<?= $user->getLink() ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Laps completed:</th>
|
||||
<td>
|
||||
<?= $race->n_laps ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div>
|
||||
<canvas id="chart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!empty($laps)): ?>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
let lapsData = JSON.parse('<?= $laps ?>');
|
||||
|
@ -129,3 +136,4 @@
|
|||
});
|
||||
|
||||
</script>
|
||||
<?php endif ?>
|
||||
|
|
|
@ -582,11 +582,11 @@ sd-carcategoryselection {
|
|||
}
|
||||
|
||||
#open-menu {
|
||||
background-image: url(/img/menu.svg);
|
||||
background-image: url('/img/menu.svg');
|
||||
}
|
||||
|
||||
#close-menu {
|
||||
background-image: url(/img/backburger.svg);
|
||||
background-image: url('/img/backburger.svg');
|
||||
}
|
||||
|
||||
#menu {
|
||||
|
|
Loading…
Reference in New Issue