/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Practice::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'golfer_id' => $this->golfer_id, 'course_id' => $this->course_id, 'start_time' => $this->start_time, 'start_hole' => $this->start_hole, 'holes' => $this->holes, 'tees_id' => $this->tees_id, 'handicap' => $this->handicap, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getPractice() { return $this->hasOne(Practice::className(), ['id' => 'practice_id']); }
echo $form->field($model, 'tees_id')->widget(DepDrop::classname(), ['options' => ['id' => 'tees-id'], 'pluginOptions' => ['depends' => ['course-id'], 'placeholder' => 'Select...', 'url' => Url::to(['/golfer/practice/tees'])]]); ?> <?php echo $form->field($model, 'start_time')->widget(DateTimePicker::classname(), ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]]); ?> <?php echo $form->field($model, 'start_hole')->dropDownList(array(1 => '1', 10 => '10')); ?> <?php echo $form->field($model, 'holes')->dropDownList(array(18 => '18', 9 => '9')); ?> <?php echo $form->field($model, 'status')->dropDownList(Practice::getLocalizedConstants('STATUS_')); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('igolf', 'Add') : Yii::t('igolf', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
<?php use kartik\detail\DetailView; use yii\helpers\ArrayHelper; use common\models\Course; use common\models\Practice; use yii\helpers\Url; /* @var $this yii\web\View */ /* @var $model app\models\Practice */ ?> <div class="practice-view"> <?php echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h3>' . $this->title . '</h3>'], 'labelColOptions' => ['style' => 'width: 30%'], 'attributes' => [['attribute' => 'course_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'options' => ['id' => 'course-id'], 'items' => ArrayHelper::map(Course::find()->asArray()->all(), 'id', 'name'), 'value' => $model->course ? $model->course->name : ''], ['attribute' => 'tees_id', 'type' => DetailView::INPUT_DEPDROP, 'value' => $model->tees ? $model->tees->name : '', 'widgetOptions' => ['pluginOptions' => ['depends' => ['course-id'], 'placeholder' => 'Select...', 'url' => Url::to(['/golfer/practice/tees'])], 'data' => $model->tees ? [$model->tees_id => $model->tees->name] : []]], ['attribute' => 'start_time', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]]], ['attribute' => 'start_hole', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => array(1 => '1', 10 => '10')], ['attribute' => 'holes', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => array(18 => '18', 9 => '9')], 'handicap', ['attribute' => 'status', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Practice::getLocalizedConstants('STATUS_')]]]); ?> </div>
/** * Finds the Practice model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Practice the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Practice::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getPractices() { return $this->hasMany(Practice::className(), ['tees_id' => 'id']); }