1. Go to this page and download the library: Download logicalcrow/pricing-plans 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/ */
logicalcrow / pricing-plans example snippets
// config/app.php
'providers' => [
// Other service providers...
Logicalcrow\PricingPlans\PricingPlansServiceProvider::class,
],
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Logicalcrow\PricingPlans\Contracts\Subscriber;
use Logicalcrow\PricingPlans\Models\Concerns\Subscribable;
class User extends Authenticatable implements Subscriber
{
use Subscribable;
// ...
}
namespace App\Models;
use Logicalcrow\PricingPlans\Models\Feature as Model;
class Feature extends Model
{
const FEATURE_UPLOAD_IMAGES = 'upload-images';
const FEATURE_UPLOAD_VIDEO = 'upload-video';
}
namespace App\Models;
use Logicalcrow\PricingPlans\Models\Plan as Model;
class Plan extends Model
{
const PLAN_FREE = 'free';
const PLAN_PRO = 'pro';
}
use Logicalcrow\PricingPlans\Models\PlanSubscription;
// Get subscriptions by plan:
$subscriptions = PlanSubscription::byPlan($plan_id)->get();
// Get subscription by subscriber:
$subscription = PlanSubscription::bySubscriber($user)->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();