/** * Finds the DcEquipment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return DcEquipment the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DcEquipment::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getEquipment() { return $this->hasOne(DcEquipment::className(), ['id' => 'equipment_id']); }
public function initDc($stationId) { if ($stationId > 0) { // insert dc equipment status $dcEquips = DcEquipment::find()->all(); if (!empty($dcEquips)) { foreach ($dcEquips as $dcEquip) { $dataEquipStatus[] = [$stationId, $dcEquip->id]; } Yii::$app->db->createCommand()->batchInsert('dc_equipment_status', ['station_id', 'equipment_id'], $dataEquipStatus)->execute(); } } }