$data['name'], 'insert_time' => time(), ]; $ProductCategory_id = $this->insertGetId($insert_data); return $ProductCategory_id; } /** * 写入数据 * @author 唐远望 * @version 1.0 * @date 2025-12-18 * @param $data * @return bool */ public function addProductCategory($data) { DB::beginTransaction(); try { $this->addProductCategory_content($data); DB::commit(); return true; // 成功处理... } catch (\Exception $e) { DB::rollBack(); // 错误处理... return false; } } /** * 编辑内容 * @author 唐远望 * @version 1.0 * @date 2025-12-18 * @param $data * @return bool */ public function editProductCategory_content($where, $data) { $ProductCategory = $this->where($where)->first(); if (!$ProductCategory) { return false; } $ProductCategory->name = $data['name']; $ProductCategory->update_time = time(); $ProductCategory->save(); return true; } /** * 更新数据 * @author 唐远望 * @version 1.0 * @date 2025-12-18 * @param $data * @return bool */ public function updateProductCategory($where, $data) { DB::beginTransaction(); try { $this->editProductCategory_content($where, $data); DB::commit(); return true; // 成功处理... } catch (\Exception $e) { DB::rollBack(); // 错误处理... return false; } } /** * 修改状态 * @author 唐远望 * @version 1.0 * @date 2025-12-18 * @param $id * @param $status * @return bool */ public function changeStatus($where, $status) { $ProductCategory = $this->where($where)->first(); if (!$ProductCategory) { return false; } $ProductCategory->status = $status; $ProductCategory->update_time = time(); $ProductCategory->save(); return true; } /** * 删除数据 * @author 唐远望 * @version 1.0 * @date 2025-12-18 * @param $id * @return bool */ public function deleteProductCategory($where) { $ProductCategory = $this->where($where)->first(); if (!$ProductCategory) { return false; } $ProductCategory->delete(); return true; } }