public function actionCatalogDetail() { $modelSocial = Social::findOne(1); $modelCategiry = Category::find()->limit(4)->asArray()->all(); $item_id = Yii::$app->request->get('item'); $itemsModel = Items::findOne($item_id); $cat = $itemsModel->cat_id; $photosModel = Photo::getPhotos($item_id, 5); return $this->render('catalog-detail', ['itemsModel' => $itemsModel, 'modelCategiry' => $modelCategiry, 'cat' => $cat, 'photosModel' => $photosModel, 'modelSocial' => $modelSocial]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Social::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'facebook', $this->facebook])->andFilterWhere(['like', 'vkontakte', $this->vkontakte])->andFilterWhere(['like', 'twitter', $this->twitter])->andFilterWhere(['like', 'google', $this->google]); return $dataProvider; }
/** * Finds the Social model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Social the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Social::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }