X7ROOT File Manager
Current Path:
/home/gfecatvj/sites/realesbar/vendor/laravel/cashier/src
home
/
gfecatvj
/
sites
/
realesbar
/
vendor
/
laravel
/
cashier
/
src
/
📁
..
📄
Billable.php
(432 B)
📄
Cashier.php
(3.44 KB)
📄
CashierServiceProvider.php
(3.35 KB)
📁
Concerns
📁
Events
📁
Exceptions
📁
Http
📄
Invoice.php
(11.72 KB)
📄
InvoiceLineItem.php
(5.6 KB)
📄
Logger.php
(655 B)
📁
Notifications
📄
Payment.php
(3.03 KB)
📄
PaymentMethod.php
(1.78 KB)
📄
Subscription.php
(27.62 KB)
📄
SubscriptionBuilder.php
(9.53 KB)
📄
SubscriptionItem.php
(5.34 KB)
📄
Tax.php
(2.01 KB)
Editing: SubscriptionItem.php
<?php namespace Laravel\Cashier; use Illuminate\Database\Eloquent\Model; use Laravel\Cashier\Concerns\InteractsWithPaymentBehavior; use Laravel\Cashier\Concerns\Prorates; use Stripe\SubscriptionItem as StripeSubscriptionItem; /** * @property \Laravel\Cashier\Subscription|null $subscription */ class SubscriptionItem extends Model { use InteractsWithPaymentBehavior; use Prorates; /** * The attributes that are not mass assignable. * * @var array */ protected $guarded = []; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'quantity' => 'integer', ]; /** * Get the subscription that the item belongs to. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function subscription() { return $this->belongsTo(Subscription::class); } /** * Increment the quantity of the subscription item. * * @param int $count * @return $this * * @throws \Laravel\Cashier\Exceptions\SubscriptionUpdateFailure */ public function incrementQuantity($count = 1) { $this->updateQuantity($this->quantity + $count); return $this; } /** * Increment the quantity of the subscription item, and invoice immediately. * * @param int $count * @return $this * * @throws \Laravel\Cashier\Exceptions\IncompletePayment * @throws \Laravel\Cashier\Exceptions\SubscriptionUpdateFailure */ public function incrementAndInvoice($count = 1) { $this->alwaysInvoice(); $this->incrementQuantity($count); return $this; } /** * Decrement the quantity of the subscription item. * * @param int $count * @return $this * * @throws \Laravel\Cashier\Exceptions\SubscriptionUpdateFailure */ public function decrementQuantity($count = 1) { $this->updateQuantity(max(1, $this->quantity - $count)); return $this; } /** * Update the quantity of the subscription item. * * @param int $quantity * @return $this * * @throws \Laravel\Cashier\Exceptions\SubscriptionUpdateFailure */ public function updateQuantity($quantity) { $this->subscription->guardAgainstIncomplete(); $stripeSubscriptionItem = $this->asStripeSubscriptionItem(); $stripeSubscriptionItem->quantity = $quantity; $stripeSubscriptionItem->payment_behavior = $this->paymentBehavior(); $stripeSubscriptionItem->proration_behavior = $this->prorateBehavior(); $stripeSubscriptionItem->save(); $this->quantity = $quantity; $this->save(); if ($this->subscription->hasSinglePlan()) { $this->subscription->quantity = $quantity; $this->subscription->save(); } return $this; } /** * Swap the subscription item to a new Stripe plan. * * @param string $plan * @param array $options * @return $this * * @throws \Laravel\Cashier\Exceptions\SubscriptionUpdateFailure */ public function swap($plan, $options = []) { $this->subscription->guardAgainstIncomplete(); $options = array_merge([ 'plan' => $plan, 'quantity' => $this->quantity, 'payment_behavior' => $this->paymentBehavior(), 'proration_behavior' => $this->prorateBehavior(), 'tax_rates' => $this->subscription->getPlanTaxRatesForPayload($plan), ], $options); $item = StripeSubscriptionItem::update( $this->stripe_id, $options, $this->subscription->owner->stripeOptions() ); $this->fill([ 'stripe_plan' => $plan, 'quantity' => $item->quantity, ])->save(); if ($this->subscription->hasSinglePlan()) { $this->subscription->fill([ 'stripe_plan' => $plan, 'quantity' => $item->quantity, ])->save(); } return $this; } /** * Swap the subscription item to a new Stripe plan, and invoice immediately. * * @param string $plan * @param array $options * @return $this * * @throws \Laravel\Cashier\Exceptions\IncompletePayment * @throws \Laravel\Cashier\Exceptions\SubscriptionUpdateFailure */ public function swapAndInvoice($plan, $options = []) { $this->alwaysInvoice(); return $this->swap($plan, $options); } /** * Update the underlying Stripe subscription item information for the model. * * @param array $options * @return \Stripe\SubscriptionItem */ public function updateStripeSubscriptionItem(array $options = []) { return StripeSubscriptionItem::update( $this->stripe_id, $options, $this->subscription->owner->stripeOptions() ); } /** * Get the subscription as a Stripe subscription item object. * * @param array $expand * @return StripeSubscriptionItem */ public function asStripeSubscriptionItem(array $expand = []) { return StripeSubscriptionItem::retrieve( ['id' => $this->stripe_id, 'expand' => $expand], $this->subscription->owner->stripeOptions() ); } }
Upload File
Create Folder