Controller und Tickets vereinheitlicht (CRUD)

This commit is contained in:
2025-06-23 14:46:12 +02:00
parent 66ff531ba4
commit d8865cbd27
16 changed files with 559 additions and 213 deletions

View File

@@ -6,19 +6,56 @@ use Blog\Model\StandortModel;
class StandortController {
protected $view;
protected $standortModel;
private $model;
private $view;
public function __construct($view) {
$this->standortModel = new StandortModel();
$this->model = new StandortModel();
$this->view = $view;
}
public function showStandorte() {
$this -> standortModel -> getStandorte();
$this->view->setVars([
"standorte" => $this->standortModel->getStandorte()
]);
$standorte = $this->model->getStandorte();
$this->view->setVars(['standorte' => $standorte]);
}
public function createStandort() {
$data = [
'straße' => $_POST['straße'],
'hausnr' => $_POST['hausnr'],
'postleitzahl' => $_POST['postleitzahl'],
'ort' => $_POST['ort'],
'land' => $_POST['land'],
'tel' => $_POST['tel'],
'email' => $_POST['email']
];
$erg = $this->model->createStandort($data);
$this->view->setVars(['standort' => $erg]);
}
public function editStandortForm() {
$id = $_GET['standortid'];
$standort = $this->model->getStandort($id);
$this->view->setVars(['standort' => $standort]);
}
public function updateStandort() {
$id = $_POST['standortid'];
$data = [
'straße' => $_POST['straße'],
'hausnr' => $_POST['hausnr'],
'postleitzahl' => $_POST['postleitzahl'],
'ort' => $_POST['ort'],
'land' => $_POST['land'],
'tel' => $_POST['tel'],
'email' => $_POST['email']
];
$erg = $this->model->updateStandort($id, $data);
$this->view->setVars(['standort' => $erg]);
}
public function deleteStandort() {
$id = $_GET['standortid'] ?? null;
$this->model->deleteStandort($id);
}
}