product_category = ProductCategory::where($field,$value); return $this->product_category->get(); } public function getProductDetailsByField($field,$value) { $this->product_details = ProductDetails::where($field,$value); return $this->product_details->get(); } public function storeProductDetails($value) { $this->product_details = new ProductDetails; $uuid = new UuidHelper; $this->product_details->pd_uuid = $uuid->generate_uuid1(); $this->product_details->code = ""; $this->product_details->name = $value['name']; $this->product_details->description = $value['description']; $this->product_details->details = $value['details']; $this->product_details->image = $value['image']; $this->product_details->is_active = 1; $this->product_details->pc_id = $value['pc_id']; if ($this->product_details->save()) { return $this->product_details->pd_id; } else { return false; } } public function storeProductCategory($value) { $this->product_category = new ProductCategory; $uuid = new UuidHelper; $this->product_category->pc_uuid = $uuid->generate_uuid1(); $this->product_category->type = $value['type']; $this->product_category->description = $value['description']; $this->product_category->is_active = 1; if ($this->product_category->save()) { return $this->product_category->pc_id; } else { return false; } } public function updateProductCategory($value) { $this->product_category = ProductCategory::where([ ['pc_id',$value['pc_id']] ])->first(); $this->product_category->type = $value['type']; $this->product_category->description = $value['description']; if ($this->product_category->save()) { return $this->product_category; } else { return false; } } public function updateProductDetails($value) { $this->product_details = ProductDetails::where([ ['pd_id',$value['pd_id']] ])->first(); $this->product_details->code = $value['code']; $this->product_details->name = $value['name']; $this->product_details->description = $value['description']; $this->product_details->details = $value['details']; $this->product_details->image = $value['image']; $this->product_details->pc_id = $value['pc_id']; $this->product_details->is_active = $value['is_active']; if ($this->product_details->save()) { return $this->product_details; } else { return false; } } public function getAllProductCategory() { return $this->product_details = ProductCategory::where([ ['is_active',1] ])->get(); } public function getProductsByCategory($pc_id) { return $this->product_details = ProductDetails::where([ ['is_active',1], ['pc_id',$pc_id], ]) ->orderBy('name') ->get(); } public function inActiveProductDetails() { ProductDetails::where('is_active', '=', 1)->update(['is_active' => 0]); } }