0) array_push($where,['erp_product.category_id', '=', $params['category_id']]); if(!is_null($params['is_serve'])) array_push($where,['erp_product.is_serve', '=', $params['is_serve']]); return $this->with(['category', 'company']) ->where($where) ->order('create_time','desc') ->paginate(['list_rows'=>10, "query" => $params]); } public function fetchByStock($params) { $where = [ ['erp_product.is_delete', '=', 0] ]; return $this->with(['category', 'company']) ->where($where) ->order('create_time','desc') ->paginate(['list_rows'=>10, "query" => $params]); } public function findProducts($text = null) { $or_where = []; if(strlen($text) > 0) { array_push($or_where, ['name|bar_code', 'like', '%'.$text.'%']); } return $this ->where('is_delete', 0) ->where($or_where) ->page(1,10) ->select(); } public function doesItExist($bar_code) { $customer = $this->where([ ["bar_code", '=', $bar_code], ["is_delete", '=', 0] ])->find(); return $customer ? true : false; } }