EventController, TicketController + Model + essenzielle Funktionen

This commit is contained in:
2025-06-16 15:12:03 +02:00
parent 5bde268b89
commit 6e3e3708b2
8 changed files with 251 additions and 7 deletions

View File

@@ -13,14 +13,12 @@ class ContactController
private $labels = array("name" => "Name", "email" => "E-Mail-Adresse", "content" => "Nachricht");
public function __construct($view)
{
public function __construct($view) {
$this->db = new ContactModel();
$this->view = $view;
}
public function showContactForm()
{
public function showContactForm() {
$this->view->setVars([
'labels' => $this->labels,
'validData' => $this->validData,
@@ -28,12 +26,11 @@ class ContactController
]);
}
public function showConfirmation()
{
public function showConfirmation() {
}
public function validateForm(){
public function validateForm() {
foreach ($this->labels as $index => $value) {
if (!isset($_POST[$index]) || empty($_POST[$index])) {
$this->errors[$index] = "Bitte " . $value . " angeben";

View File

@@ -0,0 +1,52 @@
<?php
namespace Blog\Controller;
use Blog\Model\EventModel;
class EventController {
protected $view;
protected $eventModel;
public function __construct($view) {
$this->eventModel = new EventModel();
$this->view = $view;
}
public function updateEvent() {
$event = array(
"ausstellungid" => $_POST['ausstellungid'],
"standortid" => $_POST['standortid'],
"datum_von" => $_POST['datumVon'],
"datum_bis" => $_POST['datumBis'],
"name" => $_POST['name'],
"beschreibung" => $_POST['beschreibung'],
"max_tickets" => $_POST['max_tickets'],
"preis" => $_POST['preis'],
);
$this->eventModel->updateEvent($event);
$this->view->setVars([
"ausstellungid" => $_POST['ausstellungid'],
]);
}
public function createEvent() {
$event = array(
"standortid" => $_POST['standortid'],
"datum_von" => $_POST['datumVon'],
"datum_bis" => $_POST['datumBis'],
"name" => $_POST['name'],
"beschreibung" => $_POST['beschreibung'],
"max_tickets" => $_POST['max_tickets'],
"preis" => $_POST['preis'],
);
$this->eventModel->createEvent($event);
$this->view->setVars([
"name" => $_POST['name'],
]);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Blog\Controller;
use Blog\Model\EventModel;
use Blog\Model\TicketModel;
class TicketController {
protected $view;
protected $ticketModel;
protected $eventModel;
public function __construct($view)
{
$this->ticketModel = new TicketModel();
$this->eventModel = new EventModel();
$this->view = $view;
}
public function buyTicket() {
$userId = $_POST['userId'];
$eventId = $_POST['eventId'];
$gueltigkeitsdatum = $_POST['gueltigkeitsdatum'];
$values = array("userId" => $userId,
"eventId" => $eventId,
"gueltigkeitsdatum" => $gueltigkeitsdatum);
$this->ticketModel->buyTicket($values);
$event = $this->eventModel->getEvent($eventId);
$this->view->setVars([
"event" => $event[0]
]
);
}
private function hasTicket($userId, $eventId, $gueltigkeitsdatum) {
}
}