/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Photos::find(); // add conditions that should always apply here $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->joinWith('relative'); // grid filtering conditions $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name])->orFilterWhere(['like', 'relatives.sname', $this->relative_id])->orFilterWhere(['like', 'relatives.fname', $this->relative_id])->orFilterWhere(['like', 'relatives.mname', $this->relative_id])->andFilterWhere(['like', 'descr', $this->descr]); return $dataProvider; }
/** * Finds the Photos model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Photos the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Photos::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getMrPhotos() { return $this->hasMany(Photos::className(), ['place_id' => 'id']); }
echo Html::endTag('table'); } ?> </p> </div> <!-----------------------------carousel-----------------------------------------> <div class="tab-pane" id="photos"> <div> <?php echo Html::a('Добавить фото', ['/photos/create', 'relative_id' => $model->id], ['class' => 'btn btn-primary']); ?> </div> <div class="col-lg-offset-3 col-lg-6 carousel slide" data-ride="carousel" id="image-slider"> <ol class="carousel-indicators"> <?php $photos = Photos::findAll(['relative_id' => $model->id]); $count = 0; foreach ($photos as $photo) { if ($count == 0) { $class = 'class="active"'; } else { $class = ""; } echo '<li data-target="#image-slider" data-slide-to="' . $count . '" ' . $class . '></li>'; $count++; } ?> </ol> <div class="carousel-inner"> <?php $flag = TRUE;