Download the PHP package rabol/laravel-simple-subscription without Composer

On this page you can find all versions of the php package rabol/laravel-simple-subscription. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-simple-subscription

Simple subscription package for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is a simple to use subscription package for Laravel.

It is heavvly inspired by the renvex/laravel-subscriptions package, just simpler and working :)

Sorry, My point is that the renvex packages seems to be abandond.

Payments

Installation

You can install the package via composer:

You can publish and run the migrations with:

You can publish the config file with:

This is the contents of the published config file:

Usage

Add Subscriptions to your model

For the sake of simplicity there is a trait that can be added to any model.

The most common use case is to add Subscription functionality to your User model just use the Rabol\SimpleSubscription\Traits\HasSubscriptions trait like this:

That's it, now you can use subscriptions on your user model only have to use that trait in our User model! Now your users may subscribe to plans.

Create a new Plan

`

Add a feature

Subscription plan details

Get Feature Value

There are different ways to get information about a feature on a plan To get the value of the feature 'My cool feature'.:

Get feature usage

Create a Subscription

You can subscribe a user to a plan by using the function available in the trait. First, retrieve an instance of your subscriber model, which typically will be your user model and an instance of the plan your user is subscribing to. Once you have retrieved the model instance, you may use the
method to create the model's subscription.

you can also specify the start date like this:

If no start date is specified, the subscription will start today. The end date is calculated from the settings on the plan.

Change the Plan

To change the plan do this:

If both plans (current and new plan) have the same billing frequency (e.g., invoice_period and invoice_interval) the subscription will retain the same billing dates. If the plans don't have the same billing frequency, the subscription will have the new plan billing frequency, starting on the day of the change and the subscription usage data will be cleared. Also, if the new plan has a trial period, and it's a new subscription, the trial period will be applied.

Subscription Feature Usage

There's multiple ways to determine the usage and ability of a particular feature in the user subscription, the most common one is canUseFeature:

The canUseFeature method returns true or false depending on multiple factors:

Other feature methods on the user subscription instance are:

All methods share the same signature: e.g. $user->subscription('My cool subscription')->getFeatureUsage('My cool feature');.

Record Feature Usage

In order to effectively use the ability methods you will need to keep track of every usage of each feature (or at least those that require it). You may use the recordFeatureUsage method available through the user subscription() method:

The recordFeatureUsage method accept 3 parameters: the first one is the feature's name, the second one is the quantity of uses to add (default is 1), and the third one indicates if the addition should be incremental (default behavior), when disabled the usage will be override by the quantity provided. E.g.:

Reduce Feature Usage

Reducing the feature usage is almost the same as incrementing it. Here we only substract a given quantity (default is 1) to the actual usage: The difference from the `` method is that the will not look at reset date

Increase Feature Usage

Increasing the feature usage is almost the same as . this function simply add a given quantity to the value:

One more difference from the method is that the will not look at reset date

Clear The Subscription Usage Data

Check Subscription Status

For a subscription to be considered active one of the following must be true:

Alternatively you can use the following methods available in the subscription model:

Canceled subscriptions with an active trial or ends_at in the future are considered active.

Renew a Subscription

To renew a subscription you may use the renew method available in the subscription model. This will set a new ends_at date based on the selected plan and will clear the usage data of the subscription.

Canceled subscriptions with an ended period can't be renewed.

Cancel a Subscription

To cancel a subscription, simply use the cancel method on the user's subscription:

By default the subscription will remain active until the end of the period, you may pass true to end the subscription immediately:

Scopes

Subscription Model

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-simple-subscription with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
illuminate/contracts Version ^8.0
spatie/laravel-package-tools Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rabol/laravel-simple-subscription contains the following files

Loading the files please wait ....