added ConstructionConsentController::deleteAction()

This commit is contained in:
Frank Schubert
2025-02-14 16:19:05 +01:00
parent 61b192e1c9
commit 7575ef05fb
6 changed files with 74 additions and 32 deletions

View File

@@ -10,6 +10,15 @@ class ConstructionConsentOwner extends mfBaseModel {
$this->createHistory();
}
protected function beforeDelete() {
if(!$this->id) return true;
foreach($this->getProperty("files") as $file) {
$file->delete();
}
return true;
}
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
$me = new User();
@@ -45,13 +54,16 @@ class ConstructionConsentOwner extends mfBaseModel {
if($this->$name == null) {
if($name == "files") {
if(!$this->id) return null;
if(!$this->id) return [];
$files = ConstructionConsentOwnerFile::search(["constructionconsentowner_id" => $this->id]);
if(count($files)) {
foreach($files as $file) {
$this->files[$file->filename] = $file;
}
if(!count($files)) {
return [];
}
foreach($files as $file) {
$this->files[$file->filename] = $file;
}
return $this->files;
}