Skip to content

Commit

Permalink
[13.x] Fix factory canceled state (#1282)
Browse files Browse the repository at this point in the history
* Fix factory canceled state

* Update SubscriptionFactory.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
driesvints and taylorotwell authored Nov 19, 2021
1 parent 517385e commit e2680a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions database/factories/SubscriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Str;
use Laravel\Cashier\Cashier;
use Laravel\Cashier\Subscription;
use Stripe\Price as StripePrice;
use Stripe\Subscription as StripeSubscription;

class SubscriptionFactory extends Factory
Expand Down Expand Up @@ -42,13 +43,13 @@ public function definition()
/**
* Add a price identifier to the model.
*
* @param string $price
* @param \Stripe\Price|string $price
* @return $this
*/
public function withPrice($price)
{
return $this->state([
'stripe_price' => $price,
'stripe_price' => $price instanceof StripePrice ? $price->id : $price,
]);
}

Expand Down Expand Up @@ -87,6 +88,7 @@ public function canceled()
{
return $this->state([
'stripe_status' => StripeSubscription::STATUS_CANCELED,
'ends_at' => now(),
]);
}

Expand Down

0 comments on commit e2680a1

Please sign in to comment.