Example #1
0
 public function search($params)
 {
     $query = Entity::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'param_date' => $this->param_date, 'user_id' => $this->user_id, 'mod_id' => $this->mod_id, 'system_upate' => $this->system_upate, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'deleted_at' => $this->deleted_at, 'entity_type_id' => $this->entity_type_id, 'entity_relation_id' => $this->entity_relation_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'prename', $this->prename])->andFilterWhere(['like', 'name_two', $this->name_two])->andFilterWhere(['like', 'name_three', $this->name_three])->andFilterWhere(['like', 'official_one', $this->official_one])->andFilterWhere(['like', 'official_two', $this->official_two])->andFilterWhere(['like', 'param_text', $this->param_text])->andFilterWhere(['like', 'mod_table', $this->mod_table])->andFilterWhere(['like', 'system_key', $this->system_key])->andFilterWhere(['like', 'system_name', $this->system_name]);
     return $dataProvider;
 }
 /**
  * js(on)entity returns an json object for the select2 widget
  * @param  string $search Text for the lookup
  * @param  integer of the set value
  * @return json    [description]
  */
 public function actionJsentity($search = NULL, $id = NULL)
 {
     header('Content-type: application/json');
     $clean['more'] = false;
     $query = new Query();
     if (!is_Null($search)) {
         $mainQuery = $query->select('id, name AS text')->from('{{%entity}}')->where('UPPER(name) LIKE "%' . strtoupper($search) . '%"');
         $command = $mainQuery->createCommand();
         $rows = $command->queryAll();
         $clean['results'] = array_values($rows);
     } else {
         if (!is_null($id)) {
             $clean['results'] = ['id' => $id, 'text' => Entity::findOne($id)->name];
         } else {
             $clean['results'] = ['id' => 0, 'text' => 'None found'];
         }
     }
     echo Json::encode($clean);
     exit;
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEntities()
 {
     return $this->hasMany(Entity::className(), ['entity_type_id' => 'id']);
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFromEntity()
 {
     return $this->hasOne(Entity::className(), ['id' => 'from_entity_id']);
 }
 /**
  * Finds the Entity model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Entity the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Entity::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }