Alles auf Englisch umbenannt: exhibition → event, Variablen und Tabellen angepasst, Views auf neue Felder umgestellt, Controller/Model/SQL konsistent gemacht. Alte Variablennamen raus, jetzt ist alles einheitlich. Fehler aus dem Frontend gefixt.
This commit is contained in:
61
Controller/LocationController.php
Normal file
61
Controller/LocationController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Blog\Controller;
|
||||
|
||||
use Blog\Model\LocationModel;
|
||||
|
||||
class LocationController {
|
||||
|
||||
private $model;
|
||||
private $view;
|
||||
|
||||
public function __construct($view) {
|
||||
$this->model = new LocationModel();
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function showLocations() {
|
||||
$locations = $this->model->getLocations();
|
||||
$this->view->setVars(['locations' => $locations]);
|
||||
}
|
||||
|
||||
public function createLocation() {
|
||||
$data = [
|
||||
'street' => $_POST['street'],
|
||||
'house_number' => $_POST['house_number'],
|
||||
'postal_code' => $_POST['postal_code'],
|
||||
'city' => $_POST['city'],
|
||||
'country' => $_POST['country'],
|
||||
'phone' => $_POST['phone'],
|
||||
'email' => $_POST['email']
|
||||
];
|
||||
$result = $this->model->createLocation($data);
|
||||
$this->view->setVars(['location' => $result]);
|
||||
}
|
||||
|
||||
public function editLocationForm() {
|
||||
$id = $_GET['location_id'];
|
||||
$location = $this->model->getLocation($id);
|
||||
$this->view->setVars(['location' => $location]);
|
||||
}
|
||||
|
||||
public function updateLocation() {
|
||||
$data = [
|
||||
'street' => $_POST['street'],
|
||||
'house_number' => $_POST['house_number'],
|
||||
'postal_code' => $_POST['postal_code'],
|
||||
'city' => $_POST['city'],
|
||||
'country' => $_POST['country'],
|
||||
'phone' => $_POST['phone'],
|
||||
'email' => $_POST['email']
|
||||
];
|
||||
$location_id = $_POST['location_id'];
|
||||
$result = $this->model->updateLocation($location_id, $data);
|
||||
$this->view->setVars(['location' => $result]);
|
||||
}
|
||||
|
||||
public function deleteLocation() {
|
||||
$id = $_GET['location_id'] ?? null;
|
||||
$this->model->deleteLocation($id);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user