本文整理汇总了PHP中ProductCategory::Select方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::Select方法的具体用法?PHP ProductCategory::Select怎么用?PHP ProductCategory::Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductCategory
的用法示例。
在下文中一共展示了ProductCategory::Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRootCategoryId
public function getRootCategoryId()
{
$root_cat = ProductCategory::Select('id')->whereRaw('category_level = 0 AND parent_category_id = 0')->first();
if (count($root_cat) > 0) {
$this->root_category_id = $root_cat['id'];
}
return $this->root_category_id;
}
示例2: deleteCategory
public function deleteCategory($del_category_id)
{
// check category exist or not
if (!$this->isCategoryExists($del_category_id)) {
$result_arr = array('err' => true, 'err_msg' => trans('webshoppack::admin/manageCategory.delete-category.category_not_found_msg'));
return $result_arr;
}
// check products added for the selected category or its subcategories
if ($this->isCategoryProductExists($del_category_id)) {
$result_arr = array('err' => true, 'err_msg' => trans('webshoppack::admin/manageCategory.delete-category.category_in_use_msg'));
return $result_arr;
}
// delete category details in all assigned attributes & category image.
$cat_sub_category_ids = explode(',', $this->sub_category_ids);
$cat_details = ProductCategory::whereIn('id', $cat_sub_category_ids)->get(array('id', 'image_name', 'image_ext'));
if (count($cat_details) > 0) {
foreach ($cat_details as $cat) {
// Delete all attributes assigned to the selected category & its subcategories
ProductCategoryAttributes::whereRaw('category_id = ?', array($cat->id))->delete();
// Delete category image
$this->deleteImageFiles($cat->image_name, $cat->image_ext, \Config::get("webshoppack::product_category_image_folder"));
}
}
//store the values of the left and right of the category to be deleted
//delete all those cateogries b/w the above 2
// update the cateogies to the right of the deleted category - reduce left and right bu width of the deleted category
$cat_info = ProductCategory::Select('category_left', 'category_right')->whereRaw('id = ?', array($del_category_id))->first();
if (count($cat_info) > 0) {
$category_left = $cat_info['category_left'];
$category_right = $cat_info['category_right'];
$width = $category_right - $category_left + 1;
ProductCategory::whereRaw(\DB::raw('category_left between ' . $category_left . ' AND ' . $category_right))->delete();
//To update category left
ProductCategory::whereRaw(\DB::raw('category_left > ' . $category_right))->update(array("category_left" => \DB::raw('category_left - ' . $width)));
//To update category right
ProductCategory::whereRaw(\DB::raw('category_right > ' . $category_right))->update(array("category_right" => \DB::raw('category_right - ' . $width)));
}
$result_arr = array('err' => false, 'err_msg' => '', 'category_id' => $del_category_id);
return $result_arr;
}
示例3: getCategoryName
public function getCategoryName($cat_id)
{
$category_name = '';
$cat_info = ProductCategory::Select('category_name')->whereRaw('id = ?', array($cat_id))->first();
if (count($cat_info) > 0) {
$category_name = $cat_info['category_name'];
}
return $category_name;
}