EventController, TicketController + Model + essenzielle Funktionen
This commit is contained in:
@@ -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";
|
||||
|
52
Controller/EventController.php
Normal file
52
Controller/EventController.php
Normal 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'],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
42
Controller/TicketController.php
Normal file
42
Controller/TicketController.php
Normal 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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user