Download the PHP package oanhnn/laravel-pricing-plans without Composer

On this page you can find all versions of the php package oanhnn/laravel-pricing-plans. 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-pricing-plans

Laravel Pricing Plans

Build Status Coverage Status Latest Version

Easy provide pricing plans for Your Laravel 5.4+ Application.

Main features

Easy provide pricing plans for Your Laravel 5.4+ Application.

TODO

Requirements

Installation

Composer

Begin by pulling in the package through Composer.

Service Provider

Next, if using Laravel 5.5+, you done. If using Laravel 5.4, you must include the service provider within your config/app.php file.

Config file and Migrations

Publish package config file and migrations with the command:

Then run migrations:

Contract and Traits

Add Laravel\PricingPlans\Contacts\Subscriber contract and Laravel\PricingPlans\Models\Concerns\Subscribable trait to your subscriber model (Eg. User).

See the following example:

Config File

You can configure what database tables, what models to use, list of positive words will use.

Definitions:

Take a look to the config/plans.php config file for more details.

Models

PricingPlans uses 5 models under namespace Laravel\PricingPlans\Models. You can change to using extended classes of it by changing models class in config file:

Feature model

This model is model object of feature

Plan model

This model is model object of plan

PlanFeature model

This model is relation model object between plan and feature

PlanSubscription model

This model is relation model object between plan and subscriber

PlanSubscriptionUsage model

This model is object for counting usage feature

For more details take a look to each model and the Laravel\PricingPlans\Models\Concerns\Subscribable trait.

Events

Events are under the namespace Laravel\PricingPlans\Events. The following are the events triggered by the package.

SubscriptionRenewed event

Fired when a subscription is renewed using the renew() method.

SubscriptionCanceled event

Fired when a subscription is canceled using the cancel() method.

SubscriptionPlanChanged event

Fired when a subscription's plan is changed. This will be triggered once the PlanSubscription model is saved. Plan change is determine by comparing the original and current value of plan_id.

Usage

Create features and plan

Creating subscriptions

You can subscribe a user to a plan by using the newSubscription() function available in the Subscribable 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 newSubscription method to create the model's subscription.

The first argument passed to newSubscription method should be the name of the subscription. If your application offer a single subscription, you might call this main or primary. The second argument is the plan instance your user is subscribing to.

Subscription Ability

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

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

Other methods are:

All methods share the same signature: e.g.
$user->subscription('main')->ability()->consumed(Feature::FEATURE_UPLOAD_IMAGES);.

Record Feature Usage

In order to efectively 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 record method available through the user subscriptionUsage() method:

The record method accept 3 parameters: the first one is the feature's code, 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:

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

Changelog

See all change logs in CHANGELOG

Testing

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email to Oanh Nguyen instead of using the issue tracker.

Credits

I forked and recreated this project from gerardojbaez/laraplans project in mid-2017. Thank Gerardo Baez

License

This project is released under the MIT License.
Copyright © 2017-2018 Oanh Nguyen.


All versions of laravel-pricing-plans with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/database Version ~5.4
illuminate/support Version ~5.4
nesbot/carbon Version ~1.21
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 oanhnn/laravel-pricing-plans contains the following files

Loading the files please wait ....