Skip to content

Commit

Permalink
updated subscription system
Browse files Browse the repository at this point in the history
  • Loading branch information
dipaksarkar committed Aug 30, 2023
1 parent 28e6821 commit 165d299
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/Models/Cashier/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ class Subscription extends CashierSubscription
{
use HasFeature;

/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = [
'price.plan',
];

/**
* The attributes that are mass assignable.
*
Expand All @@ -42,6 +33,17 @@ class Subscription extends CashierSubscription
'cancels_at',
];

/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = [
'price.plan',
'price.features',
'usages',
];

/**
* The event map for the model.
*
Expand Down
11 changes: 11 additions & 0 deletions src/Models/Plan/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Coderstm\Enum\PlanInterval;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

Expand Down Expand Up @@ -53,6 +54,16 @@ public function plan(): BelongsTo
return $this->belongsTo(Plan::class);
}

/**
* Get all of the features for the Plan
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function features(): HasMany
{
return $this->hasMany(Feature::class, 'plan_id', 'plan_id');
}

/**
* Determine if the plan has a payment gateway id.
*
Expand Down
2 changes: 0 additions & 2 deletions src/Traits/HasFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

trait HasFeature
{


/**
* Get all of the usages for the Subscription
*
Expand Down

0 comments on commit 165d299

Please sign in to comment.