2017 © Pedro Peláez
 

library module-subscription

image

netcore/module-subscription

  • Saturday, April 7, 2018
  • by netcorelv
  • Repository
  • 4 Watchers
  • 0 Stars
  • 148 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 1 % Grown

The README.md

Description

This module allows you to manage subscription plans and let users to subscribe to plans., (*1)

Pre-installation

Only use this module if you are using a fully custom payment method. If you use Laravel Cashier, there's support coming for that!, (*2)

This package is part of Netcore CMS ecosystem and is only functional in a project that has the following packages installed:, (*3)

  1. https://github.com/netcore/netcore
  2. https://github.com/netcore/module-admin
  3. https://github.com/netcore/module-translate

Installation

  • Require this package using composer
composer require netcore/module-subscription
  • Publish configuration/migrations
php artisan module:publish-config Subscription
php artisan module:publish-migration Subscription
php artisan migrate
  • Configure plans and billing periods in config/netcore/module-subscription.php file., (*4)

  • Seed the configuration to database, (*5)

php artisan module:seed Subscription
  • Add Modules\Subscription\Traits\Subscribable trait to your User model

Usage

  • Subscribe to a plan with price specification
$plan      = Modules\Subscription\Models\Plan::where('key', 'premium')->first();
$planPrice = $plan->prices()->inPeriod('monthly')->first();
$user      = App\User::first();
$user->subscribe($planPrice, true);
/*
 The boolean stands for whether the user has already paid for the subscription or not.
 If a boolean is not provided, it'll be automatically set to false.
*/
  • Get user plan
$plan = $user->plan;
  • Get user subscription
$subscription   = $user->subscription;
$expirationDate = $subscription->expires_at;
$userHasPaid    = $subscription->is_paid;
  • Cancel subscription
$user->cancelSubscription();
  • Renew subscription
$user->renewSubscription(true);
// The boolean stands for whether the user has already paid for the subscription or not

The Versions

07/04 2018

dev-master

9999999-dev

  Sources   Download

The Requires

 

by Jānis Blaus
by Gustavs Racenajs

07/04 2018

1.0.x-dev

1.0.9999999.9999999-dev

  Sources   Download

The Requires

 

by Gustavs Racenajs

07/04 2018

v1.0.6

1.0.6.0

  Sources   Download

The Requires

 

by Gustavs Racenajs

06/01 2018

v1.0.5

1.0.5.0

  Sources   Download

The Requires

 

by Gustavs Racenajs

04/01 2018

v1.0.4

1.0.4.0

  Sources   Download

The Requires

 

by Gustavs Racenajs

19/12 2017

v1.0.3

1.0.3.0

  Sources   Download

The Requires

 

by Gustavs Racenajs

19/12 2017

v1.0.2

1.0.2.0

  Sources   Download

The Requires

 

by Gustavs Racenajs

16/12 2017

v1.0.1

1.0.1.0

  Sources   Download

The Requires

 

by Gustavs Racenajs

12/12 2017

v1.0

1.0.0.0

  Sources   Download

The Requires

 

by Jānis Blaus