当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductCategory::insertGetId方法代码示例

本文整理汇总了PHP中ProductCategory::insertGetId方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::insertGetId方法的具体用法?PHP ProductCategory::insertGetId怎么用?PHP ProductCategory::insertGetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductCategory的用法示例。


在下文中一共展示了ProductCategory::insertGetId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addCategory

 public function addCategory($data_arr)
 {
     if (list($left_id, $right_id, $level) = $this->getNodeInfo($data_arr['parent_category_id'])) {
         ProductCategory::where('category_right', '>=', $right_id)->update(array("category_left" => \DB::raw('IF(category_left > ' . $right_id . ',category_left + 2,category_left)'), "category_right" => \DB::raw('IF(category_right >= ' . $right_id . ',category_right + 2, category_right)')));
         $data_input_arr['seo_category_name'] = $data_arr['seo_category_name'];
         $data_input_arr['category_name'] = $data_arr['category_name'];
         $data_input_arr['category_description'] = $data_arr['category_description'];
         $data_input_arr['category_meta_title'] = $data_arr['category_meta_title'];
         $data_input_arr['category_meta_description'] = $data_arr['category_meta_description'];
         $data_input_arr['category_meta_keyword'] = $data_arr['category_meta_keyword'];
         $data_input_arr['category_level'] = $this->getCategoryLevel($data_arr['parent_category_id']);
         $data_input_arr['category_left'] = $right_id;
         $data_input_arr['category_right'] = $right_id + 1;
         // available sort by options
         $available_sort_by_options = '';
         if ($data_arr['use_all_available_sort_options'] == 'Yes') {
             $available_sort_by_options = 'all';
         }
         $data_input_arr['available_sort_options'] = $available_sort_by_options;
         $data_input_arr['date_added'] = \DB::raw('NOW()');
         $data_input_arr['parent_category_id'] = $data_arr['parent_category_id'];
         $data_input_arr['status'] = $data_arr['status'];
         $img_arr = array();
         if (\Input::hasFile('category_image')) {
             $file = \Input::file('category_image');
             $image_ext = $file->getClientOriginalExtension();
             $image_name = \Str::random(20);
             $destinationpath = \URL::asset(\Config::get("webshoppack::product_category_image_folder"));
             $img_arr = $this->uploadCategoryImage($file, $image_ext, $image_name, $destinationpath, 0, 'add');
         }
         $category_id = ProductCategory::insertGetId(array_merge($data_input_arr, $img_arr));
         return $category_id;
     }
 }
开发者ID:agriya,项目名称:webshoppack,代码行数:34,代码来源:AdmipProductCategoryService.php

示例2: insertRootCategory

 public function insertRootCategory()
 {
     $id = 0;
     $root_count = ProductCategory::whereRaw('category_level = 0 AND parent_category_id = 0')->count();
     if ($root_count > 0) {
         $result = ProductCategory::Select('id')->whereRaw('category_level = 0 AND parent_category_id = 0')->first();
         $id = $result['id'];
     } else {
         $arr['seo_category_name'] = "Root";
         $arr['category_left'] = 1;
         $arr['category_right'] = 2;
         $arr['category_level'] = 0;
         $id = ProductCategory::insertGetId($arr);
     }
     return $id;
 }
开发者ID:agriya,项目名称:webshoppack,代码行数:16,代码来源:AdminManageProductCatalogService.php


注:本文中的ProductCategory::insertGetId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。