This commit is contained in:
William 2022-02-09 00:02:11 +01:00
parent fd2e8d48df
commit 55b92a3783
2 changed files with 20 additions and 6 deletions

View File

@ -24,7 +24,12 @@ class App
public function model(string $model, $injection = NULL): object
{
// Require model file
require __DIR__ . '/../model/' . $model . '.php';
$path = __DIR__ . '/../model/' . $model . '.php';
if (!file_exists($path))
{
throw new Exception("Model does not exist");
}
require $path;
// Instantiate model
if (!$injection)
{
@ -39,7 +44,12 @@ class App
// Import variables into the current symbol table from an array
extract($data);
// Require view file
require __DIR__ . '/../view/' . $view . '.php';
$path = __DIR__ . '/../view/' . $view . '.php';
if (!file_exists($path))
{
throw new Exception("View does not exist");
}
require $path;
}
// Turn data array into JSON response

View File

@ -2,7 +2,6 @@
<br>
<table>
<tr>
<th>ID</th>
<th>Navn</th>
<th>Bedrift</th>
<th>Kortnummer</th>
@ -15,9 +14,14 @@
<?php
foreach ($teams as $row) {
echo '<tr>';
foreach ($row as $key) {
echo "<td>$key</td>";
}
echo "<td>{$row['LagNavn']}</td>";
echo "<td>{$row['Bedrift']}</td>";
echo "<td>{$row['Kortnummer']}</td>";
echo "<td>{$row['Lagleder']}</td>";
echo "<td>{$row['Telefon']}</td>";
echo "<td>{$row['Deltagere']}</td>";
echo "<td>{$row['Runder']}</td>";
echo "<td>{$row['Bestetid']}</td>";
echo '</tr>';
}
?>