where('category_id', $categoryId); } public function parentId($parentId){ return $this->where('parent_id', $parentId); } public function type($type) { $q = $this; switch ($type) { case 'top': $q->where('parent_id', 0); break; case 'all': break; default: break; } return $q; } public function cropType($cropType){ return $this->where('crop_type', $cropType); } }