diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 5d06c53b3..4506d6a80 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -79,13 +79,13 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface $query = $query->whereIn('city', explode(',', array_first($param['city']))); } if (isset($param['district']) and !empty(array_filter($param['district']))) { - $query = $query->whereIn('district', explode(',',array_first($param['district']))); + $query = $query->whereIn('district', explode(',', array_first($param['district']))); } if (isset($param['neighborhood']) and !empty(array_filter($param['neighborhood']))) { - $query = $query->whereIn('neighborhood', explode(',',array_first($param['neighborhood']))); + $query = $query->whereIn('neighborhood', explode(',', array_first($param['neighborhood']))); } if (isset($param['village']) and !empty(array_filter($param['village']))) { - $query = $query->whereIn('village', explode(',',array_first($param['village']))); + $query = $query->whereIn('village', explode(',', array_first($param['village']))); } } if ($category) { @@ -147,6 +147,10 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface $query = $query->where('is_get_adv', 1); } + if (!empty($param['created_at'])) { + $query = $query->whereDate('advs_advs.created_at', $param['created_at']); + } + foreach ($param as $para => $value) { if (substr($para, 0, 3) === "cf_") { $id = substr($para, 3); @@ -420,7 +424,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface foreach ($ads as $index => $ad) { $ads[$index]->detail_url = $this->model->getAdvDetailLinkByModel($ad, 'list'); - $ads[$index]->currency_price = app(Currency::class)->format($ad->price,$ad->currency); + $ads[$index]->currency_price = app(Currency::class)->format($ad->price, $ad->currency); $ads[$index] = $this->model->AddAdsDefaultCoverImage($ad); } @@ -519,13 +523,17 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface return $ads; } - public function getUserAds($userID = null) + public function getUserAds($userID = null, $status = "approved") { $userID = auth_id_if_null($userID); - return $this->newQuery() - ->where('advs_advs.created_by_id', $userID) - ->where('status', 'approved') - ->where('finish_at', '>', date('Y-m-d H:i:s')) + + $query = $this->newQuery() + ->where('advs_advs.created_by_id', $userID); + + if ($status) { + $query = $query->where('status', $status); + } + return $query->where('finish_at', '>', date('Y-m-d H:i:s')) ->get(); } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Command/GetUserAds.php b/addons/default/visiosoft/advs-module/src/Adv/Command/GetUserAds.php index 4541f1a40..07f02dd89 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Command/GetUserAds.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Command/GetUserAds.php @@ -5,14 +5,16 @@ use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface; class GetUserAds { protected $userID; + protected $status; - public function __construct($userID) + public function __construct($userID, $status = "approved") { $this->userID = $userID; + $this->status = $status; } public function handle(AdvRepositoryInterface $advRepository) { - return $advRepository->getUserAds($this->userID); + return $advRepository->getUserAds($this->userID, $this->status); } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php index 1eaac9dac..2e5a4ed35 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php @@ -53,5 +53,5 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface public function approveAds($adsIDs); - public function getUserAds($userID = null); + public function getUserAds($userID = null, $status = "approved"); } diff --git a/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php b/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php index 733c2d8c6..484ced357 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php @@ -73,8 +73,8 @@ class AdvsModulePlugin extends Plugin ), new \Twig_SimpleFunction( 'getUserAds', - function ($userID = null) { - return $this->dispatch(new GetUserAds($userID)); + function ($userID = null, $status = "approved") { + return $this->dispatch(new GetUserAds($userID, $status)); } ), new \Twig_SimpleFunction(