Added Building::delete()
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user