/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Persons::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(['person_id' => $this->person_id, 'organization_id' => $this->organization_id, 'created' => $this->created]); $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'photo_filepath', $this->photo_filepath])->andFilterWhere(['like', 'state', $this->state]); return $dataProvider; }
<?php use yii\grid\GridView; use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model app\models\Organizations */ /* @var $searchModel app\models\PersonsSearch */ $this->title = $model->name; $this->params['breadcrumbs'][] = ['label' => 'Organizations', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $personsDataProvider = new \yii\data\ActiveDataProvider(['query' => \app\models\Persons::find()->where(['organization_id' => Yii::$app->getRequest()->getQueryParam('id')]), 'pagination' => ['pageSize' => 20]]); ?> <div class="organizations-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('Update', ['update', 'id' => $model->organization_id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Delete', ['delete', 'id' => $model->organization_id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['organization_id', 'name', 'address', 'city', 'postal_code', 'website', 'description:ntext', 'logo_filepath', 'state']]);