PHP code example of michael-rubel / laravel-couponables
1. Go to this page and download the library: Download michael-rubel/laravel-couponables library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
michael-rubel / laravel-couponables example snippets
use HasCoupons;
'--value' // The 'value' to perform calculations based on the coupon provided
'--type' // The 'type' to point out the calculation strategy
'--limit' // Limit how many times the coupon can be applied by the model
'--quantity' // Limit how many coupons are available overall (this value will decrement)
'--expires_at' // Set expiration time for the coupon
'--redeemer_type' // Polymorphic model type. Can as well be morph-mapped value, i.e. 'users'
'--redeemer_id' // Redeemer model ID
'--data' // JSON column to store any metadata you want for this particular coupon
CouponDisabledException // Coupon is disabled (`is_enabled` column).
CouponExpiredException // Coupon is expired (`expires_at` column).
InvalidCouponException // Coupon is not found in the database.
InvalidCouponTypeException // Wrong coupon type found in the database (`type` column).
InvalidCouponValueException // Wrong coupon value passed from the database (`value` column).
NotAllowedToRedeemException // Coupon is assigned to the specific model (`redeemer` morphs).
OverLimitException // Coupon is over the limit for the specific model (`limit` column).
OverQuantityException // Coupon is exhausted (`quantity` column).
CouponException // Generic exception for all cases.
$redeemer->verifyCouponOr($code, function ($code, $exception) {
// Your action with $code or $exception!
});
$redeemer->redeemCouponOr($code, function ($code, $exception) {
// Your action with $code or $exception!
});
$redeemer->isCouponAlreadyUsed($code);
$redeemer->isCouponOverLimit($code);
public function isExpired(): bool;
public function isNotExpired(): bool;
public function isDisposable(): bool;
public function isOverQuantity(): bool;
public function isRedeemedBy(Model $redeemer): bool;
public function isOverLimitFor(Model $redeemer): bool;