Finished Addressattribute

This commit is contained in:
Frank Schubert
2021-06-24 20:07:02 +02:00
parent 1b4226f762
commit 1c6acca834
5 changed files with 169 additions and 5 deletions

View File

@@ -42,7 +42,7 @@ class AddressController extends mfBaseController {
protected function saveAction() {
$r = $this->request;
$id = $r->id;
//var_dump($r);
if(is_numeric($id) && $id > 0) {
$mode = "edit";
$address = new Address($id);
@@ -94,7 +94,7 @@ class AddressController extends mfBaseController {
foreach($address->types as $existing_type) {
//var_dump($existing_type);
//var_dump($new_types);
echo $existing_type->type;
//echo $existing_type->type;
if(!in_array($existing_type->type, $new_types)) {
$existing_type->delete();
} else {
@@ -108,7 +108,19 @@ class AddressController extends mfBaseController {
$type_object = AddresstypeModel::create(['address_id' => $address->id, 'type' => $type]);
$type_object->save();
$address->types[$type] = $type_object;
}
}
$attribs = $r->attributes;
//var_dump($attribs);exit;
if(is_array($attribs) && count($attribs)) {
foreach($attribs as $atttrib => $value) {
$aa = AddressattributeModel::getFirst(["address_id" => $new_id, "name" => $attrib]);
if(!$aa) {
$aa = AddressattributeModel::create(["address_id" => $new_id, "name" => $attrib]);
}
$aa->value = $value;
$aa->save();
}
}