/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SuperPremium::find()->addSelect(['superPremium.*', 'users.last_name', 'users.first_name']);
     $query->joinWith(['users' => function ($query) {
         $query->from(['users']);
     }]);
     $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, 'manager' => $this->manager, 'client' => $this->client]);
     $dataProvider->sort->attributes['users.last_name'] = ['asc' => ['last_name' => SORT_ASC], 'desc' => ['last_name' => SORT_DESC]];
     $query->andFilterWhere(['like', 'place', $this->place])->andFilterWhere(['like', 'date', $this->date])->andFilterWhere(['like', 'comm', $this->comm])->andFilterWhere(['like', 'shop', $this->shop])->andFilterWhere(['like', 'seller', $this->seller])->andFilterWhere(['like', 'sellerPhone', $this->sellerPhone])->andFilterWhere(['LIKE', 'last_name', $this->getAttribute('last_name')]);
     return $dataProvider;
 }
Beispiel #2
0
 public function viewModel($id)
 {
     $model = SuperPremium::findOne($id);
     $model->join('LEFT JOIN', 'users', 'SuperPremium.client = users.id_user and SuperPremium.manager = users.id_user')->addSelect(['SuperPremium.*', 'users.first_name'])->where(['id' => $id])->all();
     return $model;
 }
 /**
  * Finds the SuperPremium model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SuperPremium the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SuperPremium::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #4
0
echo Html::encode($this->title);
?>
</h1>

    <?php 
var_dump($model);
?>
    <p>
        <?php 
echo Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Вы уверены, что хотите удалить эту запись?', 'method' => 'post']]);
?>
    </p>


    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => []]);
?>
    <?php 
$model = new SuperPremium();
$photos = $model->getPhotos($id);
$photosString = null;
foreach ($photos as $key => $value) {
    $photosString .= '<span class=""><img class="img-rounded col-lg-4" src="http://zoobonus.ua/images/superPremium/' . $value['photo'] . '"></span></span>';
}
echo $photosString;
?>
</div>