コード例 #1
0
ファイル: FormizinSearch.php プロジェクト: demirdaga/izin
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Formizin::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'personel_id' => $this->personel_id, 'baslangic' => $this->baslangic, 'bitis' => $this->bitis]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: Personel.php プロジェクト: demirdaga/izin
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFormizins()
 {
     return $this->hasMany(Formizin::className(), ['personel_id' => 'ID']);
 }
コード例 #3
0
ファイル: FormizinController.php プロジェクト: demirdaga/izin
 public function actionFormizin()
 {
     if (!yii::$app->user->can('yonetici-form-izin')) {
         throw new UnauthorizedHttpException();
     }
     $model = new Formizin();
     if ($model->load(Yii::$app->request->post())) {
         $personel = Personel::findOne(['user_id' => yii::$app->user->id]);
         $model->personel_id = $personel->ID;
         if ($model->save()) {
             return $this->redirect(['index']);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }