Laravel\Cashier\Subscription::applyCoupon PHP Method

applyCoupon() public method

* Apply a coupon to the subscription.
public applyCoupon ( $coupon, $removeOthers = false )
$coupon
$removeOthers
    public function applyCoupon($coupon, $removeOthers = false)
    {
        if (!$this->active()) {
            throw new InvalidArgumentException("Unable to apply coupon. Subscription not active.");
        }
        BraintreeSubscription::update($this->braintree_id, ['discounts' => ['add' => [['inheritedFromId' => $coupon]], 'remove' => $removeOthers ? $this->currentDiscounts() : []]]);
    }