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);
|
$builder->where('race_id', $tplData['race']->id);
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
|
|
||||||
|
$tplData['race']->n_laps = 0;
|
||||||
if ($query && $query->getNumRows() > 0)
|
if ($query && $query->getNumRows() > 0)
|
||||||
{
|
{
|
||||||
$tplData['laps'] = json_encode($query->getResult());
|
$tplData['laps'] = json_encode($query->getResult());
|
||||||
|
$tplData['race']->n_laps = $query->getNumRows();
|
||||||
|
}
|
||||||
|
|
||||||
$tplData['user'] = new UsersModel($tplData['race']->user_id);
|
$tplData['user'] = new UsersModel($tplData['race']->user_id);
|
||||||
$tplData['car'] = new CarsModel(getCar($tplData['race']->car_id));
|
$tplData['car'] = new CarsModel(getCar($tplData['race']->car_id));
|
||||||
$tplData['track'] = new TracksModel(getTrack($tplData['race']->track_id));
|
$tplData['track'] = new TracksModel(getTrack($tplData['race']->track_id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
echo get_header('Races');
|
echo get_header('Races');
|
||||||
echo view('race', $tplData);
|
echo view('race', $tplData);
|
||||||
echo get_footer(['chart.min.js']);
|
echo get_footer(['chart.min.js']);
|
||||||
|
|
|
@ -30,11 +30,18 @@
|
||||||
<?= $user->getLink() ?>
|
<?= $user->getLink() ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Laps completed:</th>
|
||||||
|
<td>
|
||||||
|
<?= $race->n_laps ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div>
|
<div>
|
||||||
<canvas id="chart"></canvas>
|
<canvas id="chart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if (!empty($laps)): ?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
let lapsData = JSON.parse('<?= $laps ?>');
|
let lapsData = JSON.parse('<?= $laps ?>');
|
||||||
|
@ -129,3 +136,4 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
<?php endif ?>
|
||||||
|
|
|
@ -582,11 +582,11 @@ sd-carcategoryselection {
|
||||||
}
|
}
|
||||||
|
|
||||||
#open-menu {
|
#open-menu {
|
||||||
background-image: url(/img/menu.svg);
|
background-image: url('/img/menu.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
#close-menu {
|
#close-menu {
|
||||||
background-image: url(/img/backburger.svg);
|
background-image: url('/img/backburger.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
#menu {
|
#menu {
|
||||||
|
|
Loading…
Reference in New Issue