public function checkUserHasCoupon($id) { if (ParticipantHasCoupon::findOne(['Participant_id' => Yii::$app->user->id, 'coupon_id' => $id]) !== null) { return true; } return false; }
/** * Finds the ParticipantHasCoupon model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $Participant_id * @param integer $coupon_id * @return ParticipantHasCoupon the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($Participant_id, $coupon_id) { if (($model = ParticipantHasCoupon::findOne(['Participant_id' => $Participant_id, 'coupon_id' => $coupon_id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }