#4609 default country not working fast create

This commit is contained in:
Muammer Top 2021-09-30 11:06:27 +03:00
parent 4cb72bf693
commit 30c1d170d7

View File

@ -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();