course-seite vorbereitung
This commit is contained in:
parent
509c685d80
commit
c8499aa9d5
35
Controller/CourseController.php
Normal file
35
Controller/CourseController.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Blog\Controller;
|
||||
|
||||
use Blog\Model\CourseModel;
|
||||
|
||||
class CourseController{
|
||||
private $view;
|
||||
private $db;
|
||||
|
||||
public function __construct($view){
|
||||
$this->db = new CourseModel();
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function showCoursePage(){
|
||||
$id = $_GET["courseId"] ?? null;
|
||||
if(!$id){
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$kurs = $this->db->getCourseById($id);
|
||||
if(!$kurs){
|
||||
new \Blog\Library\ErrorMsg("Kurs nicht gefunden");
|
||||
}
|
||||
|
||||
$this->view->setVars([
|
||||
"kurs" => $kurs
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
22
Model/CourseModel.php
Normal file
22
Model/CourseModel.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Blog\Model;
|
||||
|
||||
use Blog\Model\Database;
|
||||
use PDOException;
|
||||
use Random\RandomException;
|
||||
|
||||
class CourseModel extends Database
|
||||
{
|
||||
public function getCourseById(string $id){
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "SELECT k.*, o.stadt, o.strasse, o.plz
|
||||
FROM kurs k
|
||||
JOIN ort o ON k.ort_id = o.id
|
||||
WHERE k.id = :id";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([':id' => $id]);
|
||||
$result = $sth->fetch(\PDO::FETCH_ASSOC);
|
||||
return $result ?? null;
|
||||
}
|
||||
}
|
20
Views/Course/showCourse.phtml
Normal file
20
Views/Course/showCourse.phtml
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
include dirname(__DIR__).'/header.phtml';
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1><?= htmlspecialchars($kurs['titel']) ?></h1>
|
||||
<p><strong>Bewertung:</strong> <?= $kurs['bewertung'] ?> ★</p>
|
||||
<p><strong>Preis:</strong> <?= htmlspecialchars($kurs['preis']) ?>€</p>
|
||||
<p><strong>Kursleiter:</strong> <?= htmlspecialchars($kurs['leiter']) ?></p>
|
||||
<p><strong>Adresse:</strong> <?= htmlspecialchars($kurs['strasse']) ?>, <?= htmlspecialchars($kurs['plz']) ?> <?= htmlspecialchars($kurs['stadt']) ?></p>
|
||||
<p><?= nl2br(htmlspecialchars($kurs['beschreibung'] ?? '')) ?></p>
|
||||
<a href="index.php?controller=course&do=list">‹ Zurück zur Kursübersicht</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include dirname(__DIR__).'/footer.phtml'; ?>
|
@ -99,23 +99,23 @@ $location = $_GET['location'] ?? '';
|
||||
});
|
||||
}
|
||||
|
||||
foreach ($filteredKurse as $kurs): ?>
|
||||
<div class="course-card col-card-4 col-m-6">
|
||||
foreach ($filteredKurse as $kurs): ?>
|
||||
<a href="?controller=course&do=showCourse&courseId=<?= urlencode($kurs['id']) ?>" class="course-card col-card-4 col-m-6">
|
||||
<div class="course-image"></div>
|
||||
<div class="course-content">
|
||||
<div class="course-left">
|
||||
<div><?= $kurs['bewertung'] ?> ★</div>
|
||||
<div><?= $kurs['titel'] ?></div>
|
||||
<div style="min-height: 40px;">Kursleiter: <?= $kurs['leiter'] ?></div>
|
||||
<div><?= $kurs['adresse'] ?></div>
|
||||
<div class="course-content">
|
||||
<div class="course-left">
|
||||
<div><?= $kurs['bewertung'] ?> ★</div>
|
||||
<div><?= $kurs['titel'] ?></div>
|
||||
<div style="min-height: 40px;">Kursleiter: <?= $kurs['leiter'] ?></div>
|
||||
<div><?= $kurs['adresse'] ?></div>
|
||||
</div>
|
||||
<div class="course-right">
|
||||
<div><?= $kurs['preis'] ?></div>
|
||||
<div><?= $kurs['ort'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="course-right">
|
||||
<div><?= $kurs['preis'] ?></div>
|
||||
<div><?= $kurs['ort'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user