public function saveaddProducts()
 {
     $productcat_id = Input::get('productcat_id');
     $products = json_decode(Input::get('name'));
     if (!empty($products)) {
         $catName = Productcategory::find($productcat_id)->pluck('name');
         $BrandName = Productcategory::find($productcat_id)->brand->pluck('name');
         //$catName = $BrandID_CatName->name;
         //Log area
         $log['products'] = "[ {$BrandName} / {$catName} ] = " . implode(' | ', $products);
         $log['stocktype'] = 'create';
         $this->_saveActivityLog($log);
     }
     return Product::saveAll($products, $productcat_id);
 }
Example #2
0
 private function mustBeUniqueToProductCategories($productcatID)
 {
     return Productcategory::find($productcatID)->products->lists('name');
 }
 private function _monitorChildrenStatus(array $ids)
 {
     foreach ($ids as $id) {
         $cat = Productcategory::find($id);
         $status = $cat->products->lists('published');
         $cat->published = in_array(1, $status) ? 1 : 0;
         $cat->save();
     }
 }
Example #4
0
 private function deleteProductCategoriesByPrdId($productid)
 {
     $conditions = array('product_id=?', $productid);
     $result = \Productcategory::find('all', array('conditions' => $conditions));
     foreach($result as $data){
         $data->delete();
     }
 }
 private function statusChildrenCategory($productcatsID, $status)
 {
     foreach ($productcatsID as $productcat_id) {
         $cat = Productcategory::find($productcat_id);
         $cat->published = $status;
         $productsID = $cat->products->lists('id');
         if (!empty($productsID)) {
             $this->statusChildrenProduct($productsID, $status);
         }
         $cat->save();
     }
 }