```
<?php
namespace app\agent\controller;
use app\agent\model\AgentCategoryModel;
use think\Controller;
class AdminCategoryController extends Controller
{
/**
* 编辑文章分类
*/
public function edit()
{
$id = $this->request->param('id', 0, 'intval');
if ($id > 0) {
$category = AgentCategoryModel::get($id)->toArray();
$agentCategoryModel = new AgentCategoryModel();
$categoriesTree = $agentCategoryModel->adminCategoryTree($category['parent_id'], $id);
$this->assign($category);
$this->assign('categories_tree', $categoriesTree);
return $this->fetch();
} else {
$this->error('操作错误!');
}
}
}
```