From 4d56b4baf778c38c1488c832378783861e75ab81 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Thu, 16 Jan 2020 10:53:00 +0300 Subject: [PATCH] remove function --- .../src/Http/Controller/advsController.php | 113 +----------------- 1 file changed, 2 insertions(+), 111 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index 992cad425..b5c3aa9c8 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -485,117 +485,8 @@ class AdvsController extends PublicController $adv->save(); } } - if ($advModel->is_enabled('customfields')) { - - $customField_model = new CustomFieldModel(); - if ($adv->slug == "") { - //new ads - $jsonVal = []; - $id = auth()->user()->id; - $adv_id = $advRepository->getLastAd($id); - - for ($i = 1; $i < 7; $i++) { - $cat = 'cat' . $i; - if ($request->$cat != 0) { - $findcustomfields = $customField_model->getCustomfieldsJoinCategoryWithCategoryID($cat); - foreach ($findcustomfields as $findcustomfield) { - $cs_name = 'cf__' . $findcustomfield->slug; - $cf_id = "cf" . $findcustomfield->id; - if ($request->$cs_name) { - $new_cs = new CustomfieldsCustomFieldAdvsEntryModel(); - $new_cs->parent_adv_id = $adv_id; - $new_cs->custom_field_category_id = $findcustomfield->id; - $new_cs->custom_field_type = $findcustomfield->type; - if (is_array($request->$cs_name)) { - $new_cs->custom_field_value = implode(',', $request->$cs_name); - } else { - $new_cs->custom_field_value = $request->$cs_name; - } - $jsonVal[$cf_id] = $request->$cs_name; - $new_cs->save(); - } - } - } - } - - $findcustomfields = $customField_model->getCustomfieldsJoinCategoryWithCategoryID(); - foreach ($findcustomfields as $findcustomfield) { - $cs_name = 'cf__' . $findcustomfield->slug; - $cf_id = "cf" . $findcustomfield->id; - if ($request->$cs_name) { - $new_cs = new CustomfieldsCustomFieldAdvsEntryModel(); - $new_cs->parent_adv_id = $adv_id; - $new_cs->custom_field_category_id = $findcustomfield->id; - $new_cs->custom_field_type = $findcustomfield->type; - if (is_array($request->$cs_name)) { - $new_cs->custom_field_value = implode(',', $request->$cs_name); - } else { - $new_cs->custom_field_value = $request->$cs_name; - } - $jsonVal[$cf_id] = $request->$cs_name; - $new_cs->save(); - } - } - - $adv->cf_json = json_encode($jsonVal); - $adv->save(); - - } else { - //update ads - $jsonVal = []; - for ($i = 1; $i < 7; $i++) { - $cat = 'cat' . $i; - if ($request->$cat != 0) { - $findcustomfields = $customField_model->getCustomfieldsJoinCategoryWithCategoryID($cat); - foreach ($findcustomfields as $findcustomfield) { - - $cs_name = 'cf__' . $findcustomfield->slug; - $cf_id = "cf" . $findcustomfield->id; - if ($request->$cs_name) { - $new_cs = CustomfieldsCustomFieldAdvsEntryModel::query()->where('parent_adv_id', $request->update_id)->where('custom_field_category_id', $findcustomfield->id)->first(); - if (!$new_cs) { - $new_cs = new CustomfieldsCustomFieldAdvsEntryModel(); - } - $new_cs->parent_adv_id = $adv->id; - $new_cs->custom_field_category_id = $findcustomfield->id; - $new_cs->custom_field_type = $findcustomfield->type; - if (is_array($request->$cs_name)) { - $new_cs->custom_field_value = implode(',', $request->$cs_name); - } else { - $new_cs->custom_field_value = $request->$cs_name; - } - $jsonVal[$cf_id] = $request->$cs_name; - $new_cs->save(); - } - } - } - } - $findcustomfields = $customField_model->getCustomfieldsJoinCategoryWithCategoryID(); - foreach ($findcustomfields as $findcustomfield) { - - $cs_name = 'cf__' . $findcustomfield->slug; - $cf_id = "cf" . $findcustomfield->id; - if ($request->$cs_name) { - $new_cs = CustomfieldsCustomFieldAdvsEntryModel::query()->where('parent_adv_id', $request->update_id)->where('custom_field_category_id', $findcustomfield->id)->first(); - if (!$new_cs) { - $new_cs = new CustomfieldsCustomFieldAdvsEntryModel(); - } - $new_cs->parent_adv_id = $adv->id; - $new_cs->custom_field_category_id = $findcustomfield->id; - $new_cs->custom_field_type = $findcustomfield->type; - if (is_array($request->$cs_name)) { - $new_cs->custom_field_value = implode(',', $request->$cs_name); - } else { - $new_cs->custom_field_value = $request->$cs_name; - } - $jsonVal[$cf_id] = $request->$cs_name; - $new_cs->save(); - } - } - $adv->cf_json = json_encode($jsonVal); - $adv->save(); - - } + if ($this->adv_model->is_enabled('customfields')) { + app('Visiosoft\CustomfieldsModule\Http\Controller\cfController')->store($adv, $request); }