I have a table that is a tree classification table. up_id corresponds to the superior classification id. I just want to convert up_id to the name of the superior classification when displaying it in the table. What should I do? I think it can be implemented using the model's getter, but I don't know how to use it
The controller method for table data is like this
//返回分类列表数据 if(Request::isAjax()) { $list = ModelTree::order(['up_id','sort','id']) ->paginate($this->request->get('limit', 20)); $data = [ 'code' => 0, 'msg' => '正在请求中...', 'count' =>$list->count(), 'data' => $list->items() ]; return Json::create($data); }
The problem is solved, haha
How to write the model getter
How to write the controller
Display the result