PHP code example of abel-olguin / laravel-openpay-plans

1. Go to this page and download the library: Download abel-olguin/laravel-openpay-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/ */

    

abel-olguin / laravel-openpay-plans example snippets


namespace App\Models;
use AbelOlguin\OpenPayPlans\Models\Traits\HasPlans;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasPlans;
}

\AbelOlguin\OpenPayPlans\Routes\Plans::routes();

use AbelOlguin\OpenPayPlans\Controllers\Traits\Subscriptions;

class SubscriptionController
{
    use Subscriptions;
    ...
}

Route::middleware('plans:pro,trial')->get();

Route::middleware('plans.active')->get();

use Illuminate\Support\Facades\Gate;
if (!Gate::forUser($user)->allows('has-plan', 'trial')) {
  abort(403);
}

use Illuminate\Support\Facades\Gate;
if (!Gate::forUser($user)->allows('has-active-plan')) {
  abort(403);
}

use Illuminate\Support\Facades\Gate;
if (!Gate::forUser($user)->allows('create-plan')) {
  abort(403);
}
bash
composer  vendor:publish --provider="AbelOlguin\OpenPayPlans\PlansProvider"

php artisan migrate
bash 
    php artisan plans:generate
    
bash 
    php artisan plans:delete
    
bash 
    php artisan plans:check