public function setConfig($config = []) { parent::setConfig($config); if (($m = $this->getWidgetModel()) && ($structure = $m->structure) && ($this->shopProductUrlId = array_get($structure, 'product_id'))) { } else { $this->shopProductUrlId = app('router')->getCurrentRoute()->getParameter('product_id'); $this->shopProductUrlPattern = app('router')->getCurrentRoute()->getParameter('shop_product_url_pattern'); } return $this; }
public function setConfig($config = []) { parent::setConfig($config); if ($m = $this->getWidgetModel() && ($structure = $m->structure) && ($searchBy = array_get($structure, 'category_id'))) { } else { $searchBy = app('router')->getCurrentRoute()->getParameter('shop_category_url_pattern'); } $this->shopCategory = \Cache::remember($this->getCacheKey('shopCategory'), $this->getCacheTime(), function () use($searchBy) { $categoryModel = app('\\App\\Telenok\\Shop\\Model\\ProductCategory'); return $categoryModel::active()->withPermission()->where(function ($query) use($categoryModel, $searchBy) { $query->where($categoryModel->getTable() . '.url_pattern', $searchBy); $query->orWhere($categoryModel->getTable() . '.id', $searchBy); })->active()->first(); }); return $this; }
public function setConfig($config = []) { parent::setConfig($config); if ($m = $this->getWidgetModel()) { $structure = $m->structure; $this->perPage = array_get($structure, 'per_page', $this->perPage); $this->categoryIds = (array) array_get($structure, 'category_ids'); $this->ignorePage = (bool) array_get($structure, 'ignore_page', $this->ignorePage); $this->orderBy = array_get($structure, 'order_by', $this->orderBy); } else { $this->perPage = $this->getConfig('per_page', $this->perPage); $this->categoryIds = (array) $this->getConfig('category_ids', $this->categoryIds); $this->ignorePage = (bool) $this->getConfig('ignore_page', $this->ignorePage); $this->orderBy = $this->getConfig('order_by', $this->orderBy); $this->closureQuery = $this->getConfig('closure_query', $this->closureQuery); } $this->page = $this->getRequest()->get('p', $this->page); $this->shopCategoryUrlPattern = app('router')->getCurrentRoute()->getParameter('shop_category_url_pattern'); return $this; }