예제 #1
0
 /**
  * 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.');
     }
 }
예제 #2
0
 public function getEquipment()
 {
     return $this->hasOne(DcEquipment::className(), ['id' => 'equipment_id']);
 }
예제 #3
0
 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();
         }
     }
 }