From 034014cefe109cb6c9a44f7668fa5a61364a81f9 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Tue, 3 Dec 2024 06:51:10 +0100 Subject: [PATCH] feat: rename relation to on feature Model and refactor Models --- src/Models/Feature.php | 34 +++++++++++------------ src/Models/Plan.php | 46 ++++++++++++++++---------------- src/Models/Subscription.php | 42 ++++++++++++++--------------- src/Models/SubscriptionUsage.php | 18 ++++++------- 4 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/Models/Feature.php b/src/Models/Feature.php index d4efca9..df7839a 100755 --- a/src/Models/Feature.php +++ b/src/Models/Feature.php @@ -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 { @@ -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 @@ -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')); } diff --git a/src/Models/Plan.php b/src/Models/Plan.php index 80fa9b0..fb8d6b4 100755 --- a/src/Models/Plan.php +++ b/src/Models/Plan.php @@ -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 { diff --git a/src/Models/Subscription.php b/src/Models/Subscription.php index 71dbe74..cfc19b7 100755 --- a/src/Models/Subscription.php +++ b/src/Models/Subscription.php @@ -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 { diff --git a/src/Models/SubscriptionUsage.php b/src/Models/SubscriptionUsage.php index 1afbcf9..50c422f 100755 --- a/src/Models/SubscriptionUsage.php +++ b/src/Models/SubscriptionUsage.php @@ -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 {