AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
``` <?php namespace app\agent\model; use think\Model; class AgentCategoryModel extends Model { /** * 添加文章分类 * @param $data * @return bool */ public function addCategory($data) { $result = true; self::startTrans(); try { $this->allowField(true)->save($data); $id = $this->id; if (empty($data['parent_id'])) { $this->where( ['id' => $id])->update(['path' => '0-' . $id]); } else { $parentPath = $this->where('id', intval($data['parent_id']))->value('path'); $this->where( ['id' => $id])->update(['path' => "$parentPath-$id"]); } self::commit(); } catch (\Exception $e) { self::rollback(); $result = false; } return $result; } } ```