public function getContent() { return $this->hasMany(InsightsContent::className(), ['id_insights_def' => 'id']); }
/** * Finds the InsightsContent model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return InsightsContent the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = InsightsContent::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Deletes an existing InsightsDef model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete() { $post = Yii::$app->request->post(); InsightsContent::findOne($post['InsightsContent']['id'])->delete(); $this->findModel($post['InsightsDef']['name'])->delete(); return $this->redirect(['create']); }