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

[14.x] Fix wrong foreignKey on SubscriptionItem #1494

Merged
merged 2 commits into from
Jan 25, 2023
Merged

Conversation

zofe
Copy link
Contributor

@zofe zofe commented Jan 25, 2023

This pull request fixes an error in the relationship between items and subscription when using custom models

i.e. using

        Cashier::useSubscriptionModel(StripeSubscription::class);
        Cashier::useSubscriptionItemModel(StripeSubscriptionItem::class);

With these I think "licit" migrations

        Schema::create('stripe_subscriptions', function (Blueprint $table) {
            $table->id();
            ....
        });
        Schema::create('stripe_subscription_items', function (Blueprint $table) {
            $table->id();
            $table->foreignId('stripe_subscription_id');
            ...
        });

current codebase works in finding the items from the subscription, but not in finding the subscription from the items.
so $item->subscription will never works without this fix.

Of course, it can be solved by overriding the relation in our custom SubscriptionItemModel..
but I think that is a correct pr.

zofe and others added 2 commits January 25, 2023 17:04
fix wrong fk from SubscriptionItem to Subscription (needed on customized migrations)
@driesvints driesvints changed the title fix wrong foreignKey on SubscriptionItem [14.x] Fix wrong foreignKey on SubscriptionItem Jan 25, 2023
driesvints

This comment was marked as duplicate.

Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm 👍

@taylorotwell taylorotwell merged commit 79e315f into laravel:14.x Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants