Merge pull request #251 from openclassify/vedat

remove is_active for Response
This commit is contained in:
Fatih Alp 2020-01-23 14:36:44 +03:00 committed by GitHub
commit 45749c39d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 47 deletions

View File

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

View File

@ -1,37 +0,0 @@
<?php namespace Visiosoft\AdvsModule\Adv;
/**
* Created by PhpStorm.
* User: emek
* Date: 13.12.2018
* Time: 17:54
*/
use Visiosoft\AdvsModule\Adv\Contract\AdvInterface;
use Illuminate\Routing\ResponseFactory;
class AdvResponse {
protected $container;
function __construct(ResponseFactory $response)
{
$this->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);
}
}
}

View File

@ -4,5 +4,4 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
interface AdvInterface extends EntryInterface
{
public function is_active();
}

View File

@ -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 {