1. Go to this page and download the library: Download jeanfprado/cashier 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/ */
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Jeanfprado\Cashier\Subscribable;
use Jeanfprado\Cashier\Contracts\Subscribable as SubscribableContract;
class User extends Authenticatable implements SubscribableContract
{
use Subscribable;
}
use Jeanfprado\Cashier\Models\Product;
use Jeanfprado\Cashier\Models\Subscription;
$products = Product::whereIn('slug_name', ['extra-storage', 'additional-seats'])->get();
$subscription = $user->subscribe(
$products,
Subscription::TYPE_MONTHLY, // monthly, triennial, semestrial, yearly
7 // optional trial days; falls back to config('cashier.trial_days')
);
$subscription->addProduct($product, 2); // attach or increment quantity
$subscription->removeProduct($product); // detach
$user->cancelSubscription();
if ($subscription->canGenerateBilling() && ! $subscription->hasBillingPending()) {
$billing = $subscription->generateBilling();
}