Added Building::delete()

This commit is contained in:
Frank Schubert
2021-07-20 22:48:28 +02:00
parent 7b89f65503
commit 3b1dd928a6

View File

@@ -145,5 +145,30 @@ class BuildingController extends mfBaseController {
$this->redirect("Building", "Edit", ['id' => $new_id]);
}
protected function deleteAction() {
$id = $this->request->id;
if(!is_numeric($id) || !$id) {
$this->layout()->setFlash("Objekt nicht gefunden", "error");
$this->redirect("Building");
}
$building = new Building($id);
if(!$building->id) {
$this->layout()->setFlash("Objekt nicht gefunden", "error");
$this->redirect("Building");
}
/*
if(TerminationModel::search(["building_id" => $id])) {
$this->layout()->setFlash("Das Objekt kann nicht gelöscht werden, da noch Anschlüsse zugeordnet sind.", "error");
$this->redirect("Building");
}*/
$building->delete();
$this->layout()->setFlash("Objekt gelöscht", "success");
$this->redirect("Building");
}
}