Laravel\Cashier\Billable::applyCoupon PHP Method

applyCoupon() public method

Apply a coupon to the billable entity.
public applyCoupon ( string $coupon, string $subscription = 'default', boolean $removeOthers = false ) : void
$coupon string
$subscription string
$removeOthers boolean
return void
    public function applyCoupon($coupon, $subscription = 'default', $removeOthers = false)
    {
        $subscription = $this->subscription($subscription);
        if (!$subscription) {
            throw new InvalidArgumentException("Unable to apply coupon. Subscription does not exist.");
        }
        $subscription->applyCoupon($coupon, $removeOthers);
    }