/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $id_dev = 0, $id_wp = 0)
 {
     if ($id_dev > 0) {
         $query = VoipNumbers::find()->where(['device_id' => $id_dev]);
     } elseif ($id_wp > 0) {
         $query = VoipNumbers::find()->where(['workplace_id' => $id_wp]);
     } else {
         $query = VoipNumbers::find();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['voip_number' => SORT_ASC]], 'pagination' => false]);
     $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, 'voip_number' => $this->voip_number, 'device_id' => $this->device_id]);
     $query->andFilterWhere(['like', 'secret', $this->secret])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'context', $this->context]);
     return $dataProvider;
 }
Exemple #2
0
 public function getVoips()
 {
     return $this->hasMany(VoipNumbers::className(), ['workplace_id' => 'id']);
 }
Exemple #3
0
 public function getVoip()
 {
     return $this->hasMany(VoipNumbers::className(), ['device_id' => 'id']);
 }
 /**
  * Finds the VoipNumbers model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return VoipNumbers the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = VoipNumbers::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #5
0
 /**
  * массив voip-номеров
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function arrayVoips()
 {
     return VoipNumbers::find()->select('voip_number as value, voip_number as label')->where('workplace_id > 0')->orderBy('workplace_id')->asArray()->all();
 }