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 public function model(string $model, $injection = NULL): object
{ {
// Require model file // 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 // Instantiate model
if (!$injection) if (!$injection)
{ {
@ -39,7 +44,12 @@ class App
// Import variables into the current symbol table from an array // Import variables into the current symbol table from an array
extract($data); extract($data);
// Require view file // 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 // Turn data array into JSON response

View File

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