Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Razz::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;
     }
     if (is_numeric($this->uid)) {
         $query->andWhere(['uid' => $this->uid ? $this->uid : null]);
     }
     if (is_numeric($this->responder_uid)) {
         $query->andWhere(['responder_uid' => $this->responder_uid ? $this->responder_uid : null]);
     }
     $query->andFilterWhere(['id' => $this->id, 'type' => $this->type, 'ended' => $this->ended, 'views' => $this->views, 'views_at' => $this->views_at, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'stream', $this->stream])->andFilterWhere(['like', 'stream_preview', $this->stream_preview])->andFilterWhere(['like', 'responder_stream', $this->responder_stream])->andFilterWhere(['like', 'responder_stream_preview', $this->responder_stream_preview])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'hash', $this->hash]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Finds the Razz model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Razz the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Razz::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }