Last active
March 9, 2022 03:54
-
-
Save najathi/8e6de28ba7ef3d902d374704bbb3e36d to your computer and use it in GitHub Desktop.
test with zgabievi/laravel-promocodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$promo = new \Gabievi\Promocodes\Promocodes(); | |
// return $promo->create($amount = 2, $reward = '25', $data = ['intent' => 'sign up promo'], $expires_in = 20, $quantity = 1, $is_disposable = false); | |
//return $promo->output(); | |
//return $promo->createDisposable($amount = 5, $reward = '25', $data = ['intent' => 'sign up promo'], $expires_in = 20, $quantity = null); | |
//return $promo->check('NJJA-4YAQ'); | |
//return $promo->redeem('NJJA-4YAQ'); | |
//return $promo->apply('4PXY-RU2R'); | |
//return $promo->all(); | |
// $promo->disable('DDLH-YX72'); | |
// return $promo->check('DDLH-YX72'); | |
// $promo->clearRedundant(); | |
$user = \App\User::find(4); | |
$redeemMessage = "Already used this code, coupon failed!"; | |
if ($promo->check('X9V2-PPJ2')) { | |
$redeemMessage = $user->redeemCode('X9V2-PPJ2', function ($promocode) use ($user) { | |
return 'Congratulations, ' . $user->name . '! We have added ' . $promocode->reward . ' points on your account'; | |
}); | |
} | |
return $redeemMessage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment