Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Perk::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;
 }
Esempio n. 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPerk()
 {
     return $this->hasOne(Perk::className(), ['id' => 'perk_id']);
 }
Esempio n. 3
0
 /**
  * Finds the Perk model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Perk the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Perk::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
 public function getPerks()
 {
     return $this->hasMany(Perk::className(), ['id' => 'perk_id'])->viaTable('worker_has_perk', ['worker_id' => 'id']);
 }
Esempio n. 5
0
<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;
?>

    <div class="form-group">
        <?php