diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 34a6266a4..a87a12e76 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -459,4 +459,14 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface return $ads; } + + public function getUserAds($userID = null) + { + $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')) + ->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 new file mode 100644 index 000000000..4541f1a40 --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Command/GetUserAds.php @@ -0,0 +1,18 @@ +userID = $userID; + } + + public function handle(AdvRepositoryInterface $advRepository) + { + return $advRepository->getUserAds($this->userID); + } +} 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 eb59f6eb2..37104c3f2 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php @@ -46,4 +46,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface public function getPopular(); public function approveAds($adsIDs); + + public function getUserAds($userID = null); } diff --git a/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php b/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php index 475def11a..40186316b 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php @@ -7,9 +7,9 @@ use Visiosoft\AdvsModule\Adv\Command\appendRequestURL; use Visiosoft\AdvsModule\Adv\Command\GetAd; use Visiosoft\AdvsModule\Adv\Command\getExchange; use Visiosoft\AdvsModule\Adv\Command\getPopular; +use Visiosoft\AdvsModule\Adv\Command\GetUserAds; use Visiosoft\AdvsModule\Adv\Command\isActive; use Visiosoft\AdvsModule\Adv\Command\LatestAds; -use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface; use Visiosoft\AdvsModule\Currency\Currency; use Visiosoft\AdvsModule\Currency\CurrencyFormat; @@ -78,6 +78,12 @@ class AdvsModulePlugin extends Plugin ->get(); } ), + new \Twig_SimpleFunction( + 'getUserAds', + function ($userID = null) { + return $this->dispatch(new GetUserAds($userID)); + } + ), new \Twig_SimpleFunction( 'getUserPassiveAdvs', function ($user = null) {