Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename relation to on feature Model and refactor Models #29

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/Models/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property-read Plan $plan
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravelcm\Subscriptions\Models\SubscriptionUsage[] $usage
* @property-read \Illuminate\Database\Eloquent\Collection|SubscriptionUsage[] $usages
*
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature byPlanId($planId)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature ordered($direction = 'asc')
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature wherePlanId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereResettableInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereResettablePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereSortOrder($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Feature whereValue($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature byPlanId($planId)
* @method static \Illuminate\Database\Eloquent\Builder|Feature ordered($direction = 'asc')
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature wherePlanId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereResettableInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereResettablePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereSortOrder($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Feature whereValue($value)
*/
class Feature extends Model implements Sortable
{
Expand Down Expand Up @@ -93,7 +93,7 @@ class Feature extends Model implements Sortable

public function getTable(): string
{
return config('laravel-subscriptions.tables.features');
return config('laravel-subscriptions.tables.features', 'features');
}

protected static function boot(): void
Expand All @@ -120,7 +120,7 @@ public function getSlugOptions(): SlugOptions
->saveSlugsTo('slug');
}

public function usage(): HasMany
public function usages(): HasMany
{
return $this->hasMany(config('laravel-subscriptions.models.subscription_usage'));
}
Expand Down
46 changes: 23 additions & 23 deletions src/Models/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravelcm\Subscriptions\Models\Feature[] $features
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravelcm\Subscriptions\Models\Subscription[] $subscriptions
*
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan ordered($direction = 'asc')
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereActiveSubscribersLimit($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereCurrency($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereGraceInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereGracePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereInvoiceInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereInvoicePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereIsActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereProrateDay($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereProrateExtendDue($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereProratePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereSignupFee($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereSortOrder($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereTrialInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereTrialPeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Plan whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan ordered($direction = 'asc')
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereActiveSubscribersLimit($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereCurrency($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereGraceInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereGracePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereInvoiceInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereInvoicePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereIsActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan wherePrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereProrateDay($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereProrateExtendDue($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereProratePeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereSignupFee($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereSortOrder($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereTrialInterval($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereTrialPeriod($value)
* @method static \Illuminate\Database\Eloquent\Builder|Plan whereUpdatedAt($value)
*/
class Plan extends Model implements Sortable
{
Expand Down
42 changes: 21 additions & 21 deletions src/Models/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,27 @@
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravelcm\Subscriptions\Models\SubscriptionUsage[] $usage
* @property-read Model $subscriber
*
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription byPlanId($planId)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription findEndedPeriod()
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription findEndedTrial()
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription findEndingPeriod($dayRange = 3)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription findEndingTrial($dayRange = 3)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription ofSubscriber(\Illuminate\Database\Eloquent\Model $subscriber)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereCanceledAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereCancelsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereEndsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription wherePlanId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereStartsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereTrialEndsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereSubscriberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\Subscription whereSubscriberType($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription byPlanId($planId)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription findEndedPeriod()
* @method static \Illuminate\Database\Eloquent\Builder|Subscription findEndedTrial()
* @method static \Illuminate\Database\Eloquent\Builder|Subscription findEndingPeriod($dayRange = 3)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription findEndingTrial($dayRange = 3)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription ofSubscriber(\Illuminate\Database\Eloquent\Model $subscriber)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereCanceledAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereCancelsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereEndsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription wherePlanId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereStartsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereTrialEndsAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereSubscriberId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Subscription whereSubscriberType($value)
*/
class Subscription extends Model
{
Expand Down
18 changes: 9 additions & 9 deletions src/Models/SubscriptionUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
* @property-read Feature $feature
* @property-read Subscription $subscription
*
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage byFeatureSlug($featureSlug)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage whereFeatureId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage whereSubscriptionId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage whereUsed($value)
* @method static \Illuminate\Database\Eloquent\Builder|\Laravelcm\Subscriptions\Models\SubscriptionUsage whereValidUntil($value)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage byFeatureSlug($featureSlug)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage whereFeatureId($value)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage whereSubscriptionId($value)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage whereUsed($value)
* @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage whereValidUntil($value)
*/
class SubscriptionUsage extends Model
{
Expand Down
Loading