PHP code example of tomatophp / filament-subscriptions
1. Go to this page and download the library: Download tomatophp/filament-subscriptions 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/ */
tomatophp / filament-subscriptions example snippets
namespace App\Models;
use Laravelcm\Subscriptions\Traits\HasPlanSubscriptions;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasPlanSubscriptions;
}
use TomatoPHP\FilamentSubscriptions\FilamentSubscriptionsProvider;
use TomatoPHP\FilamentSubscriptions\Filament\Pages\Billing;
use Filament\Panel;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->pages([
Billing::class
])
->tenantBillingProvider(new FilamentSubscriptionsProvider());
}
use Filament\Panel;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->
use TomatoPHP\FilamentSubscriptions\Facades\FilamentSubscriptions;
public function boot()
{
FilamentSubscriptions::register(
\TomatoPHP\FilamentSubscriptions\Services\Contracts\Subscriber::make()
->name('User')
->model(\App\Models\User::class)
);
}
use TomatoPHP\FilamentSubscriptions\Facades\FilamentSubscriptions;
FilamentSubscriptions::afterSubscription(function (array $data){
// your logic here
});
FilamentSubscriptions::afterRenew(function (array $data){
// your logic here
});
FilamentSubscriptions::afterChange(function (array $data){
// your logic here
});
FilamentSubscriptions::afterCanceling(function (array $data){
// your logic here
});