static function getPortfolios($example = 0) { $return = Portfolio::find()->orderBy('id'); if ($example) { if (is_array($example)) { $return->where(['example_id' => $example]); } else { $return->where(['example_id' => $example]); } } //print_r($return); return $return; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Portfolio::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]); $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'port_image', $this->port_image]); return $dataProvider; }
foreach ($examples_selected_array as $example_selected_array){ $example[]=$example_selected_array['id']; } } if (!($myPage = Yii::$app->request->get('myPage'))){ $myPage=1; } //print '('; //print_r($example); //print ')';// // Провайдер по портфолио $portfolios = new ActiveDataProvider([ 'query' => Portfolio::getPortfolios($example), 'pagination' => [ 'pageSize' => $countOnPage*$myPage, ], ]); //print_r ($model); //print '('.$model->service_id.')'; ?> <? // Меню портфолио $items = array(); $items[] = array( 'label'=>'Все',
/** * Displays homepage. * * @return mixed */ public function actionIndex() { $home = Home::find()->all(); $Portfolio = Portfolio::find()->all(); return $this->render('index', ['home' => $home, 'Portfolio' => $Portfolio]); }
?> <div class="row"> <div class="col-xs-8"> <div class="portfolio-update"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo $this->render('_form', ['model' => $model]); ?> </div> </div> <div class="col-xs-4"> <div class="portfolio-update"> <div id="portfolio"> <!-- Пример отображения --> <?php echo $this->render('../../../frontend/views/landing/index/_portfolio', ['model' => Portfolio::findOne($model->id)]); ?> </div> </div> </div> </div> <?php \yii\widgets\Pjax::end();
/** * Finds the Portfolio model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Portfolio the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Portfolio::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }