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