Added Styles to Create and Update Event
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Blog\Controller;
|
||||
|
||||
use Blog\Model\EventModel;
|
||||
use Blog\Model\StandortModel;
|
||||
|
||||
class EventController {
|
||||
|
||||
@@ -61,4 +62,40 @@ class EventController {
|
||||
$this->model->deleteEvent($id);
|
||||
$this->view->setVars(['id' => $id]);
|
||||
}
|
||||
|
||||
public function showUpdateEvent() {
|
||||
$id = $_GET['event_id'] ?? null;
|
||||
if (!$id) {
|
||||
// handle error, e.g., redirect or show error message
|
||||
$this->view->setVars(['error' => 'Keine Event-ID angegeben.']);
|
||||
return;
|
||||
}
|
||||
$event = $this->model->getEvent($id);
|
||||
if (!$event) {
|
||||
$this->view->setVars(['error' => 'Event nicht gefunden.']);
|
||||
return;
|
||||
}
|
||||
// Map DB fields to view fields if needed
|
||||
$eventView = [
|
||||
'id' => $event['event_id'],
|
||||
'name' => $event['name'],
|
||||
'start_date' => $event['start_date'],
|
||||
'end_date' => $event['end_date'],
|
||||
'location_id' => $event['location_id'],
|
||||
'description' => $event['description'],
|
||||
'max_tickets' => $event['max_tickets'],
|
||||
'ticket_price' => $event['ticket_price'],
|
||||
];
|
||||
// Fetch location name (city)
|
||||
$standortModel = new StandortModel();
|
||||
$location = $standortModel->getStandort($event['location_id']);
|
||||
$eventView['location_name'] = $location['city'] ?? '';
|
||||
$this->view->setVars(['event' => $eventView]);
|
||||
}
|
||||
|
||||
public function showCreateEvent() {
|
||||
$standortModel = new \Blog\Model\StandortModel();
|
||||
$locations = $standortModel->getStandorte();
|
||||
$this->view->setVars(['locations' => $locations]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user