/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = HowHear::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]); $query->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
public static function HowHearAboutUs() { $query = HowHear::find()->all(); return ArrayHelper::map($query, 'id', 'title'); }
/** * Finds the HowHear model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return HowHear the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = HowHear::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model backend\models\Minor */ $this->title = $model->id; $this->params['breadcrumbs'][] = ['label' => 'Minors', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="minor-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['full_name', 'full_child_name', ['attribute' => 'date', 'value' => date('d-m-Y', $model->date)], 'email:email', 'country', 'city', 'zip_code', 'phone', 'address', ['attribute' => 'adult_gender', 'contentOptions' => ['class' => 'textContact'], 'value' => $model->adult_gender == 1 ? "Male" : "Female"], ['attribute' => 'adult_dob', 'value' => date('d-m-Y', $model->date)], ['attribute' => 'child_gender', 'contentOptions' => ['class' => 'textContact'], 'value' => $model->child_gender == 1 ? "Male" : "Female"], ['attribute' => 'child_dob', 'value' => date('d-m-Y', $model->date)], 'state', ['attribute' => 'how_hear_id', 'contentOptions' => ['class' => 'textContact'], 'value' => \backend\models\HowHear::find()->where(['id' => $model->how_hear_id])->one()->title]]]); ?> </div>