public function search($params) { $query = PromoCode::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'discount' => $this->discount, 'status' => $this->status]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'code', $this->code]); return $dataProvider; }
public function checkExists($code) { return PromoCodeModel::findOne(['code' => $code]); }
public function getPromocode() { return $this->hasOne(PromoCode::className(), ['id' => 'promocode_id']); }
protected function findModel($id) { if (($model = PromoCode::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }