PHP code example of ntech-services / subscription-system-admin

1. Go to this page and download the library: Download ntech-services/subscription-system-admin 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/ */

    

ntech-services / subscription-system-admin example snippets


use NtechServices\SubscriptionSystemAdmin\SubscriptionSystemAdminPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ... other configuration
        ->plugins([
            SubscriptionSystemAdminPlugin::make()
                ->subscriptionFeatureUsage(false) // Optional: disable feature usage
                ->coupons(true) // Optional: enable coupons
        ]);
}



return [
    // Enable or disable API routes
    'enable_api_routes' => true,
    
    // Enable or disable web routes
    'enable_web_routes' => false,
    
    // API routes prefix
    'api_prefix' => 'api/ntech-subscription',
    
    // Web routes prefix
    'web_prefix' => 'ntech-subscription',
    
    // Middleware for API routes
    'api_middleware' => ['api'],
    
    // Middleware for web routes
    'web_middleware' => ['web', 'auth'],
];

use NtechServices\SubscriptionSystemAdmin\SubscriptionSystemAdminPlugin;

// In your AdminPanelProvider
SubscriptionSystemAdminPlugin::make()
    ->subscriptionFeatureUsage(true)  // Enable/disable feature usage tracking
    ->coupons(true)                   // Enable/disable coupon system

SubscriptionSystemAdminPlugin::make()
    ->subscriptionFeatureUsage(true)  // Enable/disable feature usage tracking
    ->coupons(true)                   // Enable/disable coupon system
    ->apiRoutes(true)                 // Enable/disable API routes
    ->webRoutes(false)                // Enable/disable web routes

// In your config file
'api_middleware' => ['api', 'auth:sanctum'], // or 'auth:api'

use NtechServices\SubscriptionSystem\Models\Plan;
use NtechServices\SubscriptionSystem\Models\Feature;
use NtechServices\SubscriptionSystem\Models\Subscription;

// Get all active plans with their features
$activePlans = Plan::with(['features', 'planPrices' => function($query) {
    $query->where('is_active', true);
}])->get();

// Get subscription usage for a specific feature
$usage = Subscription::with(['usages' => function($query) use ($featureId) {
    $query->where('feature_id', $featureId);
}])->find($subscriptionId);
bash
php artisan migrate:subscription-system
bash
php artisan vendor:publish --tag="subscription-system-admin-config"
bash
php artisan migrate
bash
php artisan vendor:publish --tag="subscription-system-admin-config"
bash
php artisan vendor:publish --tag="subscription-system-admin-views"
bash
php artisan vendor:publish --tag="subscription-system-admin-migrations"
bash
php artisan vendor:publish --tag="subscription-system-admin-lang"
bash
php artisan vendor:publish --tag="subscription-system-admin-views"
bash
php artisan vendor:publish --tag="subscription-system-admin-lang"