?> <?php echo $form->field($model, 'address'); ?> <?php echo $form->field($model, 'show_on_map'); ?> <?php echo $form->field($model, 'html'); ?> <?php echo $form->field($model, 'query_id')->dropDownList(\yii\helpers\ArrayHelper::map(\app\models\Query::find()->all(), 'id', 'name')); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
public static function count($id) { return Query::find()->where(['author_id' => Yii::$app->user->id])->where(['query_id' => $id])->count(); }
/** * Finds the Query model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Query the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Query::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function takeAll() { $query = Query::find(); return $query->where(['author_id' => Yii::$app->user->isGuest ? 0 : Yii::$app->user->id])->all(); }
public function getQuery() { return $this->hasOne(Query::className(), ['id' => 'query_id']); }