Skip to content

Commit

Permalink
[14.x] Fix soft deleted customers (#1599)
Browse files Browse the repository at this point in the history
* Fix soft deleted customers

* wip
  • Loading branch information
driesvints authored Nov 8, 2023
1 parent 2d7c343 commit 3a676cc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Cashier.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Cashier;

use Illuminate\Database\Eloquent\SoftDeletes;
use Money\Currencies\ISOCurrencies;
use Money\Currency;
use Money\Formatter\IntlMoneyFormatter;
Expand Down Expand Up @@ -107,7 +108,13 @@ public static function findBillable($stripeId)
{
$stripeId = $stripeId instanceof StripeCustomer ? $stripeId->id : $stripeId;

return $stripeId ? (new static::$customerModel)->where('stripe_id', $stripeId)->first() : null;
$model = static::$customerModel;

$builder = in_array(SoftDeletes::class, class_uses_recursive($model))
? $model::withTrashed()
: new $model;

return $stripeId ? $builder->where('stripe_id', $stripeId)->first() : null;
}

/**
Expand Down

0 comments on commit 3a676cc

Please sign in to comment.