PHP code example of goodwong / laravel-subscription
1. Go to this page and download the library: Download goodwong/laravel-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/ */
namespace App\User\Entities;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* membership
*/
public function plan()
{
return $this->hasOne('Goodwong\LaravelSubscription\Entities\Subscription')
// ->where('type', 'plan')
->orderBy('id', 'desc')
;
}
/**
* The "booting" method of the model.
*
* @return void
*/
protected static function boot()
{
parent::boot();
static::addGlobalScope('plan', function (Builder $builder) {
$builder->with('plan');
});
}
}
shell
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.