From bcbe46e9925ad62263510769d13187eaf8ca2ae5 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Thu, 23 Jan 2020 13:56:38 +0300 Subject: [PATCH] remove is_active for Response --- .../advs-module/src/Adv/AdvModel.php | 16 ++++---- .../advs-module/src/Adv/AdvResponse.php | 37 ------------------- .../src/Adv/Contract/AdvInterface.php | 1 - .../src/Http/Controller/advsController.php | 2 +- 4 files changed, 9 insertions(+), 47 deletions(-) delete mode 100644 addons/default/visiosoft/advs-module/src/Adv/AdvResponse.php diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index 3f2f53070..298b90ca7 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php @@ -47,16 +47,16 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface return $isActive->enabled; } - public function is_active() + public function is_active($id) { $isActive = $this->query() - ->where('advs_advs.id', $this->id) + ->where('advs_advs.id', $id) ->where('advs_advs.slug', '!=', "") ->first(); if ($isActive->status != 'approved') { return 0; - } else - return true; + } + return 1; } public function getAdv($id = null, $nullable_ad = false) @@ -273,11 +273,11 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface $adv = $this->getAdv($id); $stock = $adv->stock; if ($stock == NULL or $stock == 0) { - return "false"; + return 0; } elseif ($stock < $quantity) { - return "false";//Adet yetmiyorsa + return 0;//Adet yetmiyorsa } else { - return "true"; + return 1; } } @@ -346,7 +346,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface if (!is_null($adv)) { return $this->where('advs_advs.slug', '!=', "") ->where('advs_advs.status', 'approved') - ->where('advs_advs.id','!=', $id) + ->where('advs_advs.id', '!=', $id) ->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s')) ->where('advs_advs.cat1', $adv->cat1)->get(); } diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvResponse.php b/addons/default/visiosoft/advs-module/src/Adv/AdvResponse.php deleted file mode 100644 index bbbd50d23..000000000 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvResponse.php +++ /dev/null @@ -1,37 +0,0 @@ -response = $response; - } - - public function make(AdvInterface $adv) { - if (!$adv->getResponse()) { - - $response = $this->response->view( - 'visiosoft.module.advs::ad-detail/detail', - [ - 'adv' => $adv, - ] - ); - - if (!$adv->is_active()) { - $response->setTtl(0); - } - - $adv->setResponse($response); - } - } -} \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php index 14ffaac7b..6f022c006 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvInterface.php @@ -4,5 +4,4 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; interface AdvInterface extends EntryInterface { - public function is_active(); } 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 1e7337400..aee9ec6d0 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -887,7 +887,7 @@ class AdvsController extends PublicController $status = $advmodel->stockControl($id, $quantity); $response = array(); - if ($status == "true") { + if ($status == 1) { $response['newQuantity'] = $advRepository->getQuantity($quantity, $type, $adv); } else {