Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = U2BranchModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('1=0');
         return $dataProvider;
     }
     $query->andFilterWhere(['branch_id' => $this->branch_id, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 public function assigned()
 {
     $dbranch = \app\models\master\U2Branch::find()->select('branch_id')->where('user_id=:duser', [':duser' => \Yii::$app->user->id])->column();
     return $this->andFilterWhere(['in', 'branch_id', count($dbranch) > 0 ? $dbranch : [-1]]);
 }
Exemplo n.º 3
0
 /**
  * Finds the U2Branch model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $branch_id
  * @param integer $user_id
  * @return U2Branch the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($branch_id, $user_id)
 {
     if (($model = U2Branch::findOne(['branch_id' => $branch_id, 'user_id' => $user_id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }