/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AdminToCompany::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(['admin_id' => $this->admin_id, 'company_id' => $this->company_id]);
     return $dataProvider;
 }
Beispiel #2
0
 public function checkValidCompany($id)
 {
     $admin_id = Yii::$app->user->identity->id;
     $admintocomp = AdminToCompany::find();
     if (Yii::$app->user->identity->type == 'normal') {
         $admintocomp = $admintocomp->where('admin_id=' . $admin_id);
         $admintocomp = $admintocomp->andWhere('company_id=' . $id);
     }
     $admintocomp = $admintocomp->asArray();
     $admintocomp = $admintocomp->all();
     if (count($admintocomp) == 0) {
         return $this->redirect(['company/']);
     }
 }