diff --git a/addons/default/visiosoft/advs-module/src/Adv/Form/SimpleAdvFormHandler.php b/addons/default/visiosoft/advs-module/src/Adv/Form/SimpleAdvFormHandler.php index 176bc5632..aae52965a 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Form/SimpleAdvFormHandler.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Form/SimpleAdvFormHandler.php @@ -2,6 +2,8 @@ use Anomaly\Streams\Platform\Ui\Form\FormBuilder; use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface; +use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface; +use Visiosoft\LocationModule\Country\CountryModel; class SimpleAdvFormHandler { @@ -11,12 +13,14 @@ class SimpleAdvFormHandler return; } - if (!$builder->getFormValue('created_by_id')) { - $builder->setFormValue('created_by_id', auth()->id()); - } - $builder->saveForm(); + if (!$builder->getFormValue('country_id')) { + $entry = $builder->getFormEntry(); + $entry->setAttribute('country_id', setting_value('visiosoft.module.location::default_country')); + $entry->save(); + } + $ad = $advRepository->find($builder->getFormEntryId()); if (!$builder->getFormValue('status') && $ad->status !== 'approved') { $ad->approve();