コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: Promocode.php プロジェクト: pistol88/yii2-promocode
 public function checkExists($code)
 {
     return PromoCodeModel::findOne(['code' => $code]);
 }
コード例 #3
0
 public function getPromocode()
 {
     return $this->hasOne(PromoCode::className(), ['id' => 'promocode_id']);
 }
コード例 #4
0
 protected function findModel($id)
 {
     if (($model = PromoCode::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }