Exemple #1
0
 /**
  * Delete current Estate and related records (LinkCounters, Counters, Records)
  *
  * @param int $id
  * @return \yii\web\Response
  * @throws ForbiddenHttpException
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionDelete($id)
 {
     $model = $this->findEstate($id);
     $linkCounters = LinkCounter::findAll(['estate_id' => $model->id]);
     foreach ($linkCounters as $linkCounter) {
         /** @var Counter $counter */
         $counter = Counter::findOne($linkCounter->getCounterId());
         Record::deleteAll(['counter_id' => $counter->id]);
         $counter->delete();
         $linkCounter->delete();
     }
     $model->delete();
     Yii::$app->session->setFlash('success', Yii::t('app', 'FLASH_ESTATE_DELETED'));
     return $this->redirect(['index']);
 }
Exemple #2
0
 /**
  * Getter currnet Counter
  *
  * @return Counter
  */
 public function getCounter()
 {
     return Counter::findOne($this->counter_id);
 }