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

Duplicate Feature Slug #26

Open
200-0K opened this issue Nov 4, 2024 · 9 comments
Open

Duplicate Feature Slug #26

200-0K opened this issue Nov 4, 2024 · 9 comments

Comments

@200-0K
Copy link

200-0K commented Nov 4, 2024

I have multiple subscription plans (free, pro, premium), each with features that share the same slug but have different values depending on the plan. When I attempt to save two features with the same slug, a number suffix is added due to the unique constraint on the feature slug. What’s the best way to handle this? Should I create separate feature slugs for each plan, or is there a recommended approach to manage features with shared slugs across plans?

image

@harrisonratcliffe
Copy link

I had the same issue. I've forked this project to rebuild it to get rid of this issue so I might publish it if you need it. Plus a few other improvements.

@200-0K
Copy link
Author

200-0K commented Nov 18, 2024

After searching for too long, I decided to create a package myself since none met my requirements. Feel free to check it out here: https://github.com/200-0K/larasub

Note: It's still under development, so stability is a work in progress.

@harrisonratcliffe
Copy link

After searching for too long, I decided to create a package myself since none met my requirements. Feel free to check it out here: https://github.com/200-0K/larasub

Note: It's still under development, so stability is a work in progress.

Nice, does it have the ability to set features to not reset? ie if I wanted a user to have 1 domain, the usage never resets unless its manually removed/reset?

@200-0K
Copy link
Author

200-0K commented Nov 18, 2024

Nice, does it have the ability to set features to not reset? ie if I wanted a user to have 1 domain, the usage never resets unless its manually removed/reset?

Yes you can. Plan's features can be resetable by period or fixed until the end of a subscription

@harrisonratcliffe
Copy link

Nice, does it have the ability to set features to not reset? ie if I wanted a user to have 1 domain, the usage never resets unless its manually removed/reset?

Yes you can. Plan's features can be resetable by period or fixed until the end of a subscription

Oh I had a look your docs but I can't find a way to set a single feature reset period to fixed. How is that achieved?

@200-0K
Copy link
Author

200-0K commented Nov 18, 2024

Nice, does it have the ability to set features to not reset? ie if I wanted a user to have 1 domain, the usage never resets unless its manually removed/reset?

Yes you can. Plan's features can be resetable by period or fixed until the end of a subscription

Oh I had a look your docs but I can't find a way to set a single feature reset period to fixed. How is that achieved?

Updated 👍

Basic Usage > Create a Plan

In the example, the Plan includes three features. The first feature has a reset period of 1 day. The other two, since the resetPeriod method wasn't explicitly called, will remain fixed throughout the subscription period

@harrisonratcliffe
Copy link

Nice, does it have the ability to set features to not reset? ie if I wanted a user to have 1 domain, the usage never resets unless its manually removed/reset?

Yes you can. Plan's features can be resetable by period or fixed until the end of a subscription

Oh I had a look your docs but I can't find a way to set a single feature reset period to fixed. How is that achieved?

Updated 👍

Basic Usage > Create a Plan

In the example, the Plan includes three features. The first feature has a reset period of 1 day. The other two, since the resetPeriod method wasn't explicitly called, will remain fixed throughout the subscription period

Nice one mate, in that case I think I'll use yours instead.

@harrisonratcliffe
Copy link

Nice, does it have the ability to set features to not reset? ie if I wanted a user to have 1 domain, the usage never resets unless its manually removed/reset?

Yes you can. Plan's features can be resetable by period or fixed until the end of a subscription

Oh I had a look your docs but I can't find a way to set a single feature reset period to fixed. How is that achieved?

Updated 👍

Basic Usage > Create a Plan

In the example, the Plan includes three features. The first feature has a reset period of 1 day. The other two, since the resetPeriod method wasn't explicitly called, will remain fixed throughout the subscription period

I'll modify the package though so there is an option to create a price_id column on tables, useful for getting the product/price from Stripe or Paddle for example to charge the client. I'll submit a PR request unless you do that before me :)

@200-0K
Copy link
Author

200-0K commented Nov 18, 2024

Feel free to modify the package as you see fit! However, I intentionally built it to focus only on subscriptions and not include payment-related functionality. This design keeps the package lightweight and flexible, making it easier to integrate with other packages

I actually created another package called Laratransaction, which focuses solely on payment transactions, and I’ve successfully integrated it with the Larasub package without modifying its tables

Integration can be done by extending the base class:

use Err0r\Larasub\Models\Subscription as Base;
use Err0r\Laratransaction\Traits\HasTransaction;

class Subscription extends Base
{
    use HasTransaction;
}

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

No branches or pull requests

2 participants