public function actionIndex() { $query = new CropTypeDo(); //父节点为根节点 $query->setParentId(1); $query->setIsDelete(0); $result = CropType::selectByCropType($query); return $this->render('index', ['cropRoot' => $result]); }
public function actionGetroot() { $modelClass = $this->modelClass; $query = new CropTypeDo(); $query->setCropId(1); $query->setIsDelete(0); $res = $modelClass::selectByCropType($query); #var_dump($res); Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return $res; }