PHP Class Laravel\Cashier\Subscription

Inheritance: extends Illuminate\Database\Eloquent\Model
Mostra file Open project: laravel/cashier-braintree Class Usage Examples

Protected Properties

Property Type Description
$dates array The attributes that should be mutated to dates.
$guarded array The attributes that aren't mass assignable.

Public Methods

Method Description
active ( ) : boolean Determine if the subscription is active.
applyCoupon ( $coupon, $removeOthers = false ) * Apply a coupon to the subscription.
asBraintreeSubscription ( ) : Braintree\Subscription Get the subscription as a Braintree subscription object.
cancel ( ) Cancel the subscription.
cancelNow ( ) Cancel the subscription immediately.
cancelled ( ) : boolean Determine if the subscription is no longer active.
markAsCancelled ( ) : void Mark the subscription as cancelled.
onGracePeriod ( ) : boolean Determine if the subscription is within its grace period after cancellation.
onTrial ( ) : boolean Determine if the subscription is within its trial period.
resume ( ) Resume the cancelled subscription.
swap ( string $plan ) Swap the subscription to a new Braintree plan.
user ( ) Get the user that owns the subscription.
valid ( ) : boolean Determine if the subscription is active, on trial, or within its grace period.

Protected Methods

Method Description
currentDiscounts ( ) : array Get the current discounts for the subscription.
getDiscountForSwitchToMonthly ( BraintreePlan $currentPlan, BraintreePlan $plan ) : object Get the discount to apply when switching to a monthly plan.
getDiscountForSwitchToYearly ( ) : object Get the discount to apply when switching to a yearly plan.
moneyRemainingOnYearlyPlan ( BraintreePlan $plan ) : float Calculate the amount of discount to apply to a swap to monthly billing.
swapAcrossFrequencies ( string $plan ) Swap the subscription to a new Braintree plan with a different frequency.
switchingToMonthlyPlan ( BraintreePlan $currentPlan, BraintreePlan $plan ) : boolean Determine if the user is switching form yearly to monthly billing.
wouldChangeBillingFrequency ( string $plan ) : boolean Determine if the given plan would alter the billing frequency.

Method Details

active() public method

Determine if the subscription is active.
public active ( ) : boolean
return boolean

applyCoupon() public method

* Apply a coupon to the subscription.
public applyCoupon ( $coupon, $removeOthers = false )
$coupon
$removeOthers

asBraintreeSubscription() public method

Get the subscription as a Braintree subscription object.
public asBraintreeSubscription ( ) : Braintree\Subscription
return Braintree\Subscription

cancel() public method

Cancel the subscription.
public cancel ( )

cancelNow() public method

Cancel the subscription immediately.
public cancelNow ( )

cancelled() public method

Determine if the subscription is no longer active.
public cancelled ( ) : boolean
return boolean

currentDiscounts() protected method

Get the current discounts for the subscription.
protected currentDiscounts ( ) : array
return array

getDiscountForSwitchToMonthly() protected method

Get the discount to apply when switching to a monthly plan.
protected getDiscountForSwitchToMonthly ( BraintreePlan $currentPlan, BraintreePlan $plan ) : object
$currentPlan BraintreePlan
$plan BraintreePlan
return object

getDiscountForSwitchToYearly() protected method

Get the discount to apply when switching to a yearly plan.
protected getDiscountForSwitchToYearly ( ) : object
return object

markAsCancelled() public method

Mark the subscription as cancelled.
public markAsCancelled ( ) : void
return void

moneyRemainingOnYearlyPlan() protected method

Calculate the amount of discount to apply to a swap to monthly billing.
protected moneyRemainingOnYearlyPlan ( BraintreePlan $plan ) : float
$plan BraintreePlan
return float

onGracePeriod() public method

Determine if the subscription is within its grace period after cancellation.
public onGracePeriod ( ) : boolean
return boolean

onTrial() public method

Determine if the subscription is within its trial period.
public onTrial ( ) : boolean
return boolean

resume() public method

Resume the cancelled subscription.
public resume ( )

swap() public method

Swap the subscription to a new Braintree plan.
public swap ( string $plan )
$plan string

swapAcrossFrequencies() protected method

Swap the subscription to a new Braintree plan with a different frequency.
protected swapAcrossFrequencies ( string $plan )
$plan string

switchingToMonthlyPlan() protected method

Determine if the user is switching form yearly to monthly billing.
protected switchingToMonthlyPlan ( BraintreePlan $currentPlan, BraintreePlan $plan ) : boolean
$currentPlan BraintreePlan
$plan BraintreePlan
return boolean

user() public method

Get the user that owns the subscription.
public user ( )

valid() public method

Determine if the subscription is active, on trial, or within its grace period.
public valid ( ) : boolean
return boolean

wouldChangeBillingFrequency() protected method

Determine if the given plan would alter the billing frequency.
protected wouldChangeBillingFrequency ( string $plan ) : boolean
$plan string
return boolean

Property Details

$dates protected_oe property

The attributes that should be mutated to dates.
protected array $dates
return array

$guarded protected_oe property

The attributes that aren't mass assignable.
protected array $guarded
return array