Skip to content

Commit

Permalink
Fix fetching of cashier customer model (#28)
Browse files Browse the repository at this point in the history
* Fix fetching of cashier customer model

Properly fetch the customer model via `Cashier::$customerModel` instead from config (config option is deprecated for Cashier 13)

* Style update

* Refer to stripe_price instead of the plan.

Co-authored-by: Rudolf Halas <[email protected]>
  • Loading branch information
reppair and rudowastaken authored May 11, 2022
1 parent f658a9e commit fb40bc0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Http/Controllers/DatabaseSubscriptionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LimeDeck\NovaCashierOverview\Http\Controllers;

use Laravel\Cashier\Cashier;
use Laravel\Cashier\Subscription;

class DatabaseSubscriptionsController extends Controller
Expand All @@ -12,10 +13,11 @@ class DatabaseSubscriptionsController extends Controller
*/
public function show($billableId)
{
$stripeModel = $this->config->get('cashier.model');
$customerModel = Cashier::$customerModel;

/** @var \Illuminate\Database\Eloquent\Model $billableModel */
$billableModel = (new $stripeModel());
$billableModel = (new $customerModel());

/** @var \Laravel\Cashier\Billable|\Illuminate\Database\Eloquent\Model $billable */
$billable = $billableModel->find($billableId);

Expand All @@ -42,7 +44,7 @@ public function show($billableId)
protected function formatSubscription(Subscription $subscription)
{
return array_merge($subscription->toArray(), [
'plan' => $subscription->stripe_plan,
'plan' => $subscription->stripe_price,
'ended' => $subscription->ended(),
'cancelled' => $subscription->cancelled(),
'active' => $subscription->active(),
Expand Down

0 comments on commit fb40bc0

Please sign in to comment.