Commit ddebd16b449ac753854a5dfd97c46292ab88c493
1 parent
f6ea8941
test
Showing
4 changed files
with
309 additions
and
0 deletions
Show diff stats
.htaccess
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace common\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use yii\base\Model; | ||
| 7 | +use yii\data\ActiveDataProvider; | ||
| 8 | +use common\models\Blog; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * BlogSearch represents the model behind the search form about `common\models\Blog`. | ||
| 12 | + */ | ||
| 13 | +class BlogSearch extends Blog | ||
| 14 | +{ | ||
| 15 | + /** | ||
| 16 | + * @inheritdoc | ||
| 17 | + */ | ||
| 18 | + public function rules() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + [['blog_id', 'user_id', 'user_add_id', 'view_count'], 'integer'], | ||
| 22 | + [['name', 'link', 'date_add', 'description', 'cover'], 'safe'], | ||
| 23 | + ]; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @inheritdoc | ||
| 28 | + */ | ||
| 29 | + public function scenarios() | ||
| 30 | + { | ||
| 31 | + // bypass scenarios() implementation in the parent class | ||
| 32 | + return Model::scenarios(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Creates data provider instance with search query applied | ||
| 37 | + * | ||
| 38 | + * @param array $params | ||
| 39 | + * | ||
| 40 | + * @return ActiveDataProvider | ||
| 41 | + */ | ||
| 42 | + public function search($params) | ||
| 43 | + { | ||
| 44 | + $query = Blog::find(); | ||
| 45 | + | ||
| 46 | + // add conditions that should always apply here | ||
| 47 | + | ||
| 48 | + $dataProvider = new ActiveDataProvider([ | ||
| 49 | + 'query' => $query, | ||
| 50 | + ]); | ||
| 51 | + | ||
| 52 | + $this->load($params); | ||
| 53 | + | ||
| 54 | + if (!$this->validate()) { | ||
| 55 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 56 | + // $query->where('0=1'); | ||
| 57 | + return $dataProvider; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + // grid filtering conditions | ||
| 61 | + $query->andFilterWhere([ | ||
| 62 | + 'blog_id' => $this->blog_id, | ||
| 63 | + 'user_id' => $this->user_id, | ||
| 64 | + 'date_add' => $this->date_add, | ||
| 65 | + 'user_add_id' => $this->user_add_id, | ||
| 66 | + 'view_count' => $this->view_count, | ||
| 67 | + ]); | ||
| 68 | + | ||
| 69 | + $query->andFilterWhere(['like', 'name', $this->name]) | ||
| 70 | + ->andFilterWhere(['like', 'link', $this->link]) | ||
| 71 | + ->andFilterWhere(['like', 'description', $this->description]) | ||
| 72 | + ->andFilterWhere(['like', 'cover', $this->cover]); | ||
| 73 | + | ||
| 74 | + return $dataProvider; | ||
| 75 | + } | ||
| 76 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace common\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use yii\base\Model; | ||
| 7 | +use yii\data\ActiveDataProvider; | ||
| 8 | +use common\models\Gallery; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * GallerySearch represents the model behind the search form about `common\models\Gallery`. | ||
| 12 | + */ | ||
| 13 | +class GallerySearch extends Gallery | ||
| 14 | +{ | ||
| 15 | + /** | ||
| 16 | + * @inheritdoc | ||
| 17 | + */ | ||
| 18 | + public function rules() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + [['gallery_id', 'user_id', 'user_add_id', 'type'], 'integer'], | ||
| 22 | + [['name', 'date_add', 'cover', 'photo'], 'safe'], | ||
| 23 | + ]; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @inheritdoc | ||
| 28 | + */ | ||
| 29 | + public function scenarios() | ||
| 30 | + { | ||
| 31 | + // bypass scenarios() implementation in the parent class | ||
| 32 | + return Model::scenarios(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Creates data provider instance with search query applied | ||
| 37 | + * | ||
| 38 | + * @param array $params | ||
| 39 | + * | ||
| 40 | + * @return ActiveDataProvider | ||
| 41 | + */ | ||
| 42 | + public function search($params) | ||
| 43 | + { | ||
| 44 | + $query = Gallery::find(); | ||
| 45 | + | ||
| 46 | + // add conditions that should always apply here | ||
| 47 | + | ||
| 48 | + $dataProvider = new ActiveDataProvider([ | ||
| 49 | + 'query' => $query, | ||
| 50 | + ]); | ||
| 51 | + | ||
| 52 | + $this->load($params); | ||
| 53 | + | ||
| 54 | + if (!$this->validate()) { | ||
| 55 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 56 | + // $query->where('0=1'); | ||
| 57 | + return $dataProvider; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + // grid filtering conditions | ||
| 61 | + $query->andFilterWhere([ | ||
| 62 | + 'gallery_id' => $this->gallery_id, | ||
| 63 | + 'user_id' => $this->user_id, | ||
| 64 | + 'date_add' => $this->date_add, | ||
| 65 | + 'user_add_id' => $this->user_add_id, | ||
| 66 | + 'type' => $this->type, | ||
| 67 | + ]); | ||
| 68 | + | ||
| 69 | + $query->andFilterWhere(['like', 'name', $this->name]) | ||
| 70 | + ->andFilterWhere(['like', 'cover', $this->cover]) | ||
| 71 | + ->andFilterWhere(['like', 'photo', $this->photo]); | ||
| 72 | + | ||
| 73 | + return $dataProvider; | ||
| 74 | + } | ||
| 75 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace common\models; | ||
| 4 | + | ||
| 5 | + use Yii; | ||
| 6 | + use yii\base\Model; | ||
| 7 | + use yii\data\ActiveDataProvider; | ||
| 8 | + use common\models\Project; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * ProjectSearch represents the model behind the search form about `common\models\Project`. | ||
| 12 | + */ | ||
| 13 | + class ProjectSearch extends Project | ||
| 14 | + { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * @inheritdoc | ||
| 18 | + */ | ||
| 19 | + public function rules() | ||
| 20 | + { | ||
| 21 | + return [ | ||
| 22 | + [ | ||
| 23 | + [ | ||
| 24 | + 'project_id', | ||
| 25 | + 'user_id', | ||
| 26 | + 'project_pid', | ||
| 27 | + 'user_add_id', | ||
| 28 | + 'payment_variant', | ||
| 29 | + 'deadline', | ||
| 30 | + 'contractual', | ||
| 31 | + ], | ||
| 32 | + 'integer', | ||
| 33 | + ], | ||
| 34 | + [ | ||
| 35 | + [ | ||
| 36 | + 'name', | ||
| 37 | + 'link', | ||
| 38 | + 'date_add', | ||
| 39 | + 'date_end', | ||
| 40 | + 'budget', | ||
| 41 | + 'city', | ||
| 42 | + 'street', | ||
| 43 | + 'house', | ||
| 44 | + 'description', | ||
| 45 | + 'file', | ||
| 46 | + 'specializationString', | ||
| 47 | + ], | ||
| 48 | + 'safe', | ||
| 49 | + ], | ||
| 50 | + [ | ||
| 51 | + [ 'view_count' ], | ||
| 52 | + 'number', | ||
| 53 | + ], | ||
| 54 | + ]; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * @inheritdoc | ||
| 59 | + */ | ||
| 60 | + public function scenarios() | ||
| 61 | + { | ||
| 62 | + // bypass scenarios() implementation in the parent class | ||
| 63 | + return Model::scenarios(); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * Creates data provider instance with search query applied | ||
| 68 | + * | ||
| 69 | + * @param array $params | ||
| 70 | + * | ||
| 71 | + * @return ActiveDataProvider | ||
| 72 | + */ | ||
| 73 | + public function search($params) | ||
| 74 | + { | ||
| 75 | + $query = Project::find(); | ||
| 76 | + | ||
| 77 | + // add conditions that should always apply here | ||
| 78 | + | ||
| 79 | + $dataProvider = new ActiveDataProvider([ | ||
| 80 | + 'query' => $query, | ||
| 81 | + ]); | ||
| 82 | + | ||
| 83 | + $this->load($params); | ||
| 84 | + | ||
| 85 | + if(!$this->validate()) { | ||
| 86 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 87 | + // $query->where('0=1'); | ||
| 88 | + return $dataProvider; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + $query->joinWith('specializations'); | ||
| 92 | + | ||
| 93 | + // grid filtering conditions | ||
| 94 | + $query->andFilterWhere([ | ||
| 95 | + 'project_id' => $this->project_id, | ||
| 96 | + 'user_id' => $this->user_id, | ||
| 97 | + 'project_pid' => $this->project_pid, | ||
| 98 | + 'date_add' => $this->date_add, | ||
| 99 | + 'date_end' => $this->date_end, | ||
| 100 | + 'user_add_id' => $this->user_add_id, | ||
| 101 | + 'view_count' => $this->view_count, | ||
| 102 | + 'payment_variant' => $this->payment_variant, | ||
| 103 | + 'deadline' => $this->deadline, | ||
| 104 | + 'contractual' => $this->contractual, | ||
| 105 | + ]); | ||
| 106 | + | ||
| 107 | + $query->andFilterWhere([ | ||
| 108 | + 'like', | ||
| 109 | + 'name', | ||
| 110 | + $this->name, | ||
| 111 | + ]) | ||
| 112 | + ->andFilterWhere([ | ||
| 113 | + 'like', | ||
| 114 | + 'link', | ||
| 115 | + $this->link, | ||
| 116 | + ]) | ||
| 117 | + ->andFilterWhere([ | ||
| 118 | + 'like', | ||
| 119 | + 'budget', | ||
| 120 | + $this->budget, | ||
| 121 | + ]) | ||
| 122 | + ->andFilterWhere([ | ||
| 123 | + 'like', | ||
| 124 | + 'city', | ||
| 125 | + $this->city, | ||
| 126 | + ]) | ||
| 127 | + ->andFilterWhere([ | ||
| 128 | + 'like', | ||
| 129 | + 'street', | ||
| 130 | + $this->street, | ||
| 131 | + ]) | ||
| 132 | + ->andFilterWhere([ | ||
| 133 | + 'like', | ||
| 134 | + 'house', | ||
| 135 | + $this->house, | ||
| 136 | + ]) | ||
| 137 | + ->andFilterWhere([ | ||
| 138 | + 'like', | ||
| 139 | + 'description', | ||
| 140 | + $this->description, | ||
| 141 | + ]) | ||
| 142 | + ->andFilterWhere([ | ||
| 143 | + 'like', | ||
| 144 | + 'file', | ||
| 145 | + $this->file, | ||
| 146 | + ]) | ||
| 147 | + ->andFilterWhere([ | ||
| 148 | + 'like', | ||
| 149 | + 'specialization.specialization_name', | ||
| 150 | + $this->specializationString, | ||
| 151 | + ]); | ||
| 152 | + | ||
| 153 | + return $dataProvider; | ||
| 154 | + } | ||
| 155 | + } |