Setting preorder status triggers status update on hausnummer and

wohneinhiet
This commit is contained in:
Frank Schubert
2023-11-07 14:43:07 +01:00
parent 79fe0aa00e
commit 8b5d60f3c6
6 changed files with 173 additions and 21 deletions
+32 -1
View File
@@ -963,7 +963,38 @@ class PreorderController extends mfBaseController {
$preorder->status_id = $status_id;
$preorder->save();
return ["message" => "Status saved successfully", "id" => $preorder_id, "status_id" => $status->id, "status_code" => $status->code, "status_text" => $status->name];
$update = [
"preorder" => [
"status" => [
"id" => $status->id,
"code" => $status->code,
"text" => $status->name
]
]
];
if($preorder->adb_hausnummer_id) {
$update["building"] = [
"status" => [
"id" => $preorder->adb_hausnummer->status->id,
"code" => $preorder->adb_hausnummer->status->code,
"text" => $preorder->adb_hausnummer->status->name
]
];
}
if($preorder->adb_wohneinheit_id) {
$update["unit"] = [
"status" => [
"id" => $preorder->adb_wohneinheit->status->id,
"code" => $preorder->adb_wohneinheit->status->code,
"text" => $preorder->adb_wohneinheit->status->name
]
];
}
return ["message" => "Status saved successfully", "id" => $preorder_id, "update" => $update];
}
}