Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Projects::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(['id' => $this->id, 'created_date' => $this->created_date, 'updated_date' => $this->updated_date, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'title_en', $this->title_en])->andFilterWhere(['like', 'title_ru', $this->title_ru])->andFilterWhere(['like', 'title_am', $this->title_am])->andFilterWhere(['like', 'description_en', $this->description_en])->andFilterWhere(['like', 'description_ru', $this->description_ru])->andFilterWhere(['like', 'description_am', $this->description_am])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'attachment', $this->attachment]);
     return $dataProvider;
 }
Exemple #2
0
 public function actionServices()
 {
     $pages = new Pagination(['totalCount' => Projects::find()->count(), 'forcePageParam' => false, 'pageSizeParam' => false, 'defaultPageSize' => 1]);
     $projects = Projects::find()->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('services', ['projects' => $projects, 'pages' => $pages]);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProjects()
 {
     return $this->hasMany(Projects::className(), ['status_id' => 'id']);
 }
 /**
  * Finds the Projects model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Projects the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Projects::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }