Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Dep::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', 'name', $this->name]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Finds the Dep model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Dep the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Dep::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
<div class="worker-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create Worker', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
Pjax::begin(['enablePushState' => false]);
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'name:ntext', ['attribute' => 'dep_id', 'format' => 'raw', 'filter' => ArrayHelper::map(Dep::find()->all(), 'id', 'name'), 'value' => 'dep.name'], ['format' => 'raw', 'label' => 'Навыки', 'value' => function ($data) {
    return $data->myperks;
}], ['attribute' => 'img', 'format' => 'html', 'value' => function ($data) {
    return Html::img($data->imageurl, ['width' => '100']);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
            <?php 
Pjax::end();
?>
</div>
Example #4
0
/* @var $form yii\widgets\ActiveForm */
?>

<div class="worker-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'name')->textarea(['rows' => 6]);
?>


    <?php 
echo $form->field($model, 'dep_id')->dropDownList(ArrayHelper::map(Dep::find()->all(), 'id', 'name'));
?>
    <?php 
echo $form->field($model, 'perks_list')->dropDownList(ArrayHelper::map(Perk::find()->all(), 'id', 'name'), ['multiple' => true]);
?>


    

    <?php 
echo $form->field($model, 'img')->fileInput();
?>

    <?php 
echo $model->img ? Html::img('/uploads/' . $model->img, ['width' => 100, 'height' => 100]) : null;
?>