Merge pull request #1012 from openclassify/vedatakd

fixes
This commit is contained in:
Dia Shalabi 2021-03-29 17:43:46 +03:00 committed by GitHub
commit bbfe74bf18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 32 deletions

View File

@ -71,12 +71,8 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
public function userAdv($nullable_ad = false, $checkRole = true) public function userAdv($nullable_ad = false, $checkRole = true)
{ {
if ($user = Auth::user() and $user->hasRole('admin') && $checkRole) { return $this->getAdv(null, $nullable_ad)
return $this->getAdv(null, $nullable_ad); ->where('advs_advs.created_by_id', Auth::id());
} else {
return $this->getAdv(null, $nullable_ad)
->where('advs_advs.created_by_id', Auth::id());
}
} }
public function getAdvByCat($cat_id) public function getAdvByCat($cat_id)
@ -142,7 +138,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
$responseBodyAsString = $response->getBody()->getContents(); $responseBodyAsString = $response->getBody()->getContents();
$response = json_decode($responseBodyAsString, true); $response = json_decode($responseBodyAsString, true);
if ($showMsg) { if ($showMsg) {
$messages->error($response['error']); $messages->error($response['error']);
} }
} }
} }
@ -225,17 +221,17 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
} }
public function getAdvDetailLinkByModel($object, $type = null) public function getAdvDetailLinkByModel($object, $type = null)
{ {
if ($type != null) { if ($type != null) {
$id = $object->id; $id = $object->id;
$seo = $object->slug; $seo = $object->slug;
return \route('adv_detail_seo', [$seo, $id]); return \route('adv_detail_seo', [$seo, $id]);
} }
$id = $object->getObject()->id; $id = $object->getObject()->id;
$seo = $object->getObject()->slug; $seo = $object->getObject()->slug;
return \route('adv_detail_seo', [$seo, $id]); return \route('adv_detail_seo', [$seo, $id]);
} }
public function getAdvDetailLinkByAdId($id) public function getAdvDetailLinkByAdId($id)
{ {
@ -396,7 +392,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
public function getProductOptionsValues() public function getProductOptionsValues()
{ {
return $this->product_options_value; return $this->product_options_value;
} }
public function getStatus() public function getStatus()

View File

@ -75,16 +75,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
if ($city) { if ($city) {
$query = $query->where('city', $city->id); $query = $query->where('city', $city->id);
} elseif (isset($param['city']) and !empty(array_filter($param['city']))) { } elseif (isset($param['city']) and !empty(array_filter($param['city']))) {
$query = $query->whereIn('city', $param['city']); $query = $query->whereIn('city', explode(',', array_first($param['city'])));
} }
if (isset($param['district']) and !empty(array_filter($param['district']))) { if (isset($param['district']) and !empty(array_filter($param['district']))) {
$query = $query->whereIn('district', $param['district']); $query = $query->whereIn('district', explode(',',array_first($param['district'])));
} }
if (isset($param['neighborhood']) and !empty(array_filter($param['neighborhood']))) { if (isset($param['neighborhood']) and !empty(array_filter($param['neighborhood']))) {
$query = $query->whereIn('neighborhood', $param['neighborhood']); $query = $query->whereIn('neighborhood', explode(',',array_first($param['neighborhood'])));
} }
if (isset($param['village']) and !empty(array_filter($param['village']))) { if (isset($param['village']) and !empty(array_filter($param['village']))) {
$query = $query->whereIn('village', $param['village']); $query = $query->whereIn('village', explode(',',array_first($param['village'])));
} }
} }
if ($category) { if ($category) {

View File

@ -44,15 +44,20 @@ class OptionConfigurationController extends PublicController
{ {
if($conf = $this->optionConfigurationRepository->find($this->request->configuration)) if($conf = $this->optionConfigurationRepository->find($this->request->configuration))
{ {
$conf->name = $conf->getName(); if($conf->parent_adv->getStatus() == "approved")
{
$conf->name = $conf->getName();
if ($conf->stock < $this->request->quantity){ if ($conf->stock < $this->request->quantity){
return redirect()->back()->with('warning', [trans('visiosoft.module.carts::message.error1in2')]); return redirect()->back()->with('warning', [trans('visiosoft.module.carts::message.error1in2')]);
}else{ }else{
$cart = $this->dispatch(new GetCart()); $cart = $this->dispatch(new GetCart());
$cart->add($conf, $this->request->quantity); $cart->add($conf, $this->request->quantity);
return $this->redirect->to(route('visiosoft.module.carts::cart')); return $this->redirect->to(route('visiosoft.module.carts::cart'));
} }
}
$this->messages->info(trans('visiosoft.module.advs::message.error_added_cart'));
return back();
} }
} }

View File

@ -1229,7 +1229,7 @@ class AdvsController extends PublicController
$thisModel = new AdvModel(); $thisModel = new AdvModel();
$adv = $thisModel->isAdv($id); $adv = $thisModel->isAdv($id);
$response = array(); $response = array();
if ($adv) { if ($adv and $adv->getStatus() == "approved") {
$cart = $thisModel->addCart($adv, $quantity, $name); $cart = $thisModel->addCart($adv, $quantity, $name);
$response['status'] = "success"; $response['status'] = "success";
$count = $cart->getItems()->count; $count = $cart->getItems()->count;