/**
  * Finds the BuildPart model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BuildPart the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BuildPart::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBuildParts()
 {
     return $this->hasMany(BuildPart::className(), ['build_guide_fk' => 'build_guide_id']);
 }
Esempio n. 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBuildParts()
 {
     return $this->hasMany(BuildPart::className(), ['part_fk' => 'part_id']);
 }
Esempio n. 4
-1
 public function actionLinkPart($build_id, $part_id)
 {
     $oldLink = BuildPart::findOne(['part_fk' => Yii::$app->session['old_part_id'], 'build_guide_fk' => $build_id]);
     if ($oldLink != NULL) {
         $oldLink->part_fk = $part_id;
         $oldLink->update();
     } else {
         $build = BuildGuide::find()->where(['build_guide_id' => $build_id])->one();
         $part = Part::find()->where(['part_id' => $part_id])->one();
         $part->link('builds', $build);
     }
     return $this->redirect(['/build-guide/view', 'id' => $build_id]);
 }