1. Go to this page and download the library: Download morenorafael/subscription library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
morenorafael / subscription example snippets
'providers' => [
/**
* Third Party Service Providers...
*/
Morenorafael\Subscription\SubscriptionServiceProvider::class,
...
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Morenorafael\Subscription\Contracts\PlanSubscriberInterface;
use Morenorafael\Subscription\Traits\PlanSubscriber;
class User extends Authenticatable implements PlanSubscriberInterface
{
use PlanSubscriber;
...
use Morenorafael\Subscription\Models\PlanSubscription;
// Get subscriptions by plan:
$subscriptions = PlanSubscription::byPlan($plan_id)->get();
// Get subscription by user:
$subscription = PlanSubscription::byUser($user_id)->first();
// Get subscriptions with trial ending in 3 days:
$subscriptions = PlanSubscription::findEndingTrial(3)->get();
// Get subscriptions with ended trial:
$subscriptions = PlanSubscription::findEndedTrial()->get();
// Get subscriptions with period ending in 3 days:
$subscriptions = PlanSubscription::findEndingPeriod(3)->get();
// Get subscriptions with ended period:
$subscriptions = PlanSubscription::findEndedPeriod()->get();
// Exclude subscriptions which are canceled:
$subscriptions = PlanSubscription::excludeCanceled()->get();
// Exclude subscriptions which are immediately canceled:
$subscriptions = PlanSubscription::scopeExcludeImmediatelyCanceled()->get();
sh
php artisan vendor:publish --provider="Morenorafael\Subscription\SubscriptionServiceProvider"
sh
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.