/** * Finds the MeetingPlaceChoice model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MeetingPlace the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MeetingPlaceChoice::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function add($meeting_place_id, $user_id, $suggested_by) { $model = new MeetingPlaceChoice(); $model->meeting_place_id = $meeting_place_id; $model->user_id = $user_id; // set initial choice status based if they suggested it themselves if ($suggested_by == $user_id) { $model->status = self::STATUS_YES; } else { $model->status = self::STATUS_UNKNOWN; } $model->save(); }
/** * @return \yii\db\ActiveQuery */ public function getMeetingPlaceChoices() { return $this->hasMany(MeetingPlaceChoice::className(), ['meeting_place_id' => 'id']); }