/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Department::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'department_id' => $this->department_id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'weight' => $this->weight]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
<?php echo $form->field($model, 'first_name'); ?> <?php echo $form->field($model, 'patronymic'); ?> <?php $listdata = ArrayHelper::map(Post::find()->all(), 'id', 'title'); ?> <?php echo $form->field($model, 'post_id')->dropDownList($listdata, ['class' => 'form-control select']); ?> <?php $listdata = ArrayHelper::map(Department::find()->all(), 'id', 'title'); ?> <?php echo $form->field($model, 'department_id')->dropDownList($listdata, ['class' => 'form-control select']); ?> <?php echo $form->field($model, 'email_work'); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?> <div class="form-group"> <?php echo Html::submitButton(Yii::t('app', 'Signup'), ['class' => 'btn btn-primary', 'name' => 'signup-button']); ?>
/** * Finds the Department model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Department the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Department::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use app\components\helpers\Phone; use app\models\Post; use app\modules\department\models\Department; use app\modules\user\models\User; use yii\helpers\Html; use yii\widgets\DetailView; echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'post_id', 'value' => $model->post_id ? Post::findOne($model->post_id)->title : ''], ['attribute' => 'department_id', 'format' => 'raw', 'value' => $model->department_id ? Html::a(Department::findOne($model->department_id)->title, ['/department/view', 'id' => $model->department_id]) : ''], ['attribute' => 'user_id', 'format' => 'raw', 'value' => $model->user_id ? Html::a(User::findOne($model->user_id)->getName(), ['/user/view', 'id' => $model->user_id]) : ''], ['attribute' => 'phone_stationary', 'format' => 'raw', 'value' => Html::a(Phone::getFormatView($model->phone_work), 'tel:' . $model->phone_work)], ['attribute' => 'phone_work', 'format' => 'raw', 'value' => Html::a(Phone::getFormatView($model->phone_work), 'tel:' . $model->phone_work)], 'email_work:email', 'cabinet', 'worked_at:date', ['attribute' => 'experience', 'format' => 'raw', 'value' => $model->getExperience()], 'rate', ['attribute' => 'status', 'format' => 'raw', 'value' => 1]]]);