GithubHelp home page GithubHelp logo

Comments (13)

techguydev avatar techguydev commented on May 5, 2024

I have found that with

$user->onGenericTrial();

Works great to check if the user is on any trial, since I am handling the trial in the model.

Is there something similar to check if the user is on any active plan or should I concatenate conditional statements of each plan to check it?

from cashier-paddle.

techguydev avatar techguydev commented on May 5, 2024

This seems to work well to check if the user has any active subscription :
$user->subscriptions()->where('paddle_status','active')->count() >= 1

from cashier-paddle.

driesvints avatar driesvints commented on May 5, 2024

Hey @techguydev, that's described here: https://laravel.com/docs/7.x/cashier-paddle#checking-subscription-status

Screenshot 2020-06-22 at 13 16 33

Is that what you need?

from cashier-paddle.

techguydev avatar techguydev commented on May 5, 2024

Hi @driesvints

if ($user->subscribed('default')){

}

Works great if you have just one subscription type.

In my use case I have 3 subscriptions types:basic,pro,unlimited.

I am creating a workflow where I need to check if a given user has any subscriptions at all ( of any type) or if he/she is on trial, or on trial with a given subscription.

I might just join them like this:

if ($user->subscribed('basic') || $user->subscribed('pro') || $user->subscribed('unlimited') ){
//
}

I just wanted to know if there is any function that consider any active subscription to a given user.

from cashier-paddle.

driesvints avatar driesvints commented on May 5, 2024

Hey @techguydev, no there isn't such a feature atm it seems. If you indeed only need to check the active state you can do

$user->subscriptions()->active()->count() >= 1

But that's not the same as subscribed which takes into account "valid" subscriptions:

    /**
     * Determine if the subscription is active, on trial, or within its grace period.
     *
     * @return bool
     */
    public function valid()
    {
        return $this->active() || $this->onTrial() || $this->onPausedGracePeriod() || $this->onGracePeriod();
    }

I'll mark this as a feature request.

from cashier-paddle.

techguydev avatar techguydev commented on May 5, 2024

Thanks @driesvints

from cashier-paddle.

frkcn avatar frkcn commented on May 5, 2024

Hey @techguydev, no there isn't such a feature atm it seems. If you indeed only need to check the active state you can do

$user->subscriptions()->active()->count() >= 1

This PR fixed this problem. #22

from cashier-paddle.

techguydev avatar techguydev commented on May 5, 2024

@frkcn looks interesting this approach.

from cashier-paddle.

Hussam3bd avatar Hussam3bd commented on May 5, 2024

@techguydev

I'm not sure but I think the right approach is to keep one subscription the "default"
and create 3 plans "Basic, pro, unlimited"

then you can check if the user subscribed and which plan the user subscribed to

if ($user->subscribedToPlan($basicMonthly = 12345, 'default')) {
    //
}

I'm doing it this way in my SaaS,

from cashier-paddle.

techguydev avatar techguydev commented on May 5, 2024

Thanks @Hussam3bd

@driesvints What do you think about this approach?

from cashier-paddle.

driesvints avatar driesvints commented on May 5, 2024

In general I agree yeah. I think in your use case you want different plans but one type of subscription.

I'm gonna leave the issue open for a bit because I can still see a use case of adding a method to see if a user has any active subscription at all.

from cashier-paddle.

driesvints avatar driesvints commented on May 5, 2024

Closing this as it's now possible again to do $user->subscriptions()->active()->count() if you want.

from cashier-paddle.

techguydev avatar techguydev commented on May 5, 2024

I am not sure I am understanding the difference between Subscription and Plan.

In my casa each plan has different access to my app, so the subscription if kind of different too.

how are you guys handling different access levels with different plans?

from cashier-paddle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.