PHP code example of oanhnn / laravel-pricing-plans
1. Go to this page and download the library: Download oanhnn/laravel-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/ */
oanhnn / laravel-pricing-plans example snippets
// config/app.php
'providers' => [
// Other service providers...
Laravel\PricingPlans\PricingPlansServiceProvider::class,
],
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\PricingPlans\Contracts\Subscriber;
use Laravel\PricingPlans\Models\Concerns\Subscribable;
class User extends Authenticatable implements Subscriber
{
use Subscribable;
// ...
}
namespace App\Models;
use Laravel\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 Laravel\PricingPlans\Models\Plan as Model;
class Plan extends Model
{
const PLAN_FREE = 'free';
const PLAN_PRO = 'pro';
}
use Laravel\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();