model->where($where)->orderBy('list_order', 'desc')->orderBy('created_at', 'desc')->limit($limit)->get(); } public function getInfo($id) { $info = $this->model->where('id', $id)->first(); return $info; } public function getBread($id) { $info = $this->model->where('id', $id)->first(); $res = [['id' => $info['id'], 'name' => $info['category_name']]]; if ($info['parent_id'] != 0) { $this->_getBread($info, $res); } return $res; } private function _getBread($info, &$res) { $cate = $this->model->where('id', $info['parent_id'])->first(); array_unshift($res, ['id' => $cate['id'], 'name' => $cate['category_name']]); if ($cate['parent_id'] != 0) { $this->_getBread($cate, $res); } } }