$params['category_id'], 'unit_id' => $params['unit_id'], 'name' => $params['name'], 'image' => $params['image'], 'intro' => $params['intro'], 'conent' => $params['conent'], 'product_type' => $params['product_type'], ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑 * @param array $params * @return bool * @author likeadmin * @date 2025/07/11 11:41 */ public static function edit(array $params): bool { Db::startTrans(); try { Product::where('id', $params['id'])->update([ 'category_id' => $params['category_id'], 'unit_id' => $params['unit_id'], 'name' => $params['name'], 'image' => $params['image'], 'intro' => $params['intro'], 'conent' => $params['conent'], 'product_type' => $params['product_type'], ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除 * @param array $params * @return bool * @author likeadmin * @date 2025/07/11 11:41 */ public static function delete(array $params): bool { return Product::destroy($params['id']); } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2025/07/11 11:41 */ public static function detail($params): array { return Product::findOrEmpty($params['id'])->toArray(); } }