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


->plugin(\TomatoPHP\FilamentSubscriptions\FilamentSubscriptionsPlugin::make())

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)
    );
}

return [
    "old" => //Plan,
    "new" => //Plan,
    "subscription" => //Subscription,
]


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
});

bash
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations"
bash
php artisan vendor:publish --provider="Laravelcm\Subscriptions\SubscriptionServiceProvider"
bash
php artisan filament-subscriptions:install
bash
php artisan vendor:publish --tag="filament-subscriptions-config"
bash
php artisan vendor:publish --tag="filament-subscriptions-views"
bash
php artisan vendor:publish --tag="filament-subscriptions-lang"