tecmetrix/subscription-system

Laravel subscription system package for multi-company accounting and service management.

Maintainers

Package info

github.com/sherazahmad1989/subscription-system

pkg:composer/tecmetrix/subscription-system

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2025-11-06 09:14 UTC

This package is auto-updated.

Last update: 2026-03-06 10:02:18 UTC


README

A flexible Laravel Subscription Management Package for multi-company applications.
It allows you to define services, create packages, and manage subscriptions for each company β€” including subscription duration, start & end dates, and automatic expiration.

πŸš€ Features

βœ… Create and manage services (e.g., Accounting, Payroll, CRM, etc.)
βœ… Combine services into packages (Free, Basic, Pro, Enterprise, etc.)
βœ… Manage subscriptions for each company
βœ… Automatic expiration via Artisan command
βœ… Fully configurable and extendable
βœ… Built with Laravel best practices

🧱 Installation

Step 1 β€” Require the Package

composer require tecmetrix/subscription-system

πŸ’‘ If it’s a private repository, add it in your app’s composer.json:

"repositories": [
  {
    "type": "vcs",
    "url": "https://github.com/tecmetrix/subscription-system.git"
  }
]

Step 2 β€” Publish & Run Migrations

php artisan vendor:publish --provider="Tecmetrix\SubscriptionSystem\SubscriptionSystemServiceProvider"
php artisan migrate

This will create the following tables:

  • services
  • packages
  • package_service
  • subscriptions

Step 3 β€” Add to Your Models (Optional)

If you have a Company model, each company can have one or more subscriptions.

Example:

use Tecmetrix\SubscriptionSystem\Models\Subscription;

class Company extends Model
{
    public function subscriptions()
    {
        return $this->hasMany(Subscription::class);
    }
}

βš™οΈ Usage

🧩 1. Create Services

use Tecmetrix\SubscriptionSystem\Models\Service;

$service = Service::create([
    'name' => 'CRM Module',
    'description' => 'Manage customers and sales data'
]);

πŸ“¦ 2. Create a Package with Multiple Services

use Tecmetrix\SubscriptionSystem\Models\Package;

$package = Package::create([
    'name' => 'Pro Plan',
    'description' => 'Includes CRM and Accounting modules',
    'price' => 49.99,
    'duration_days' => 30, // monthly plan
]);

$package->services()->attach([$service->id]);

🧾 3. Subscribe a Company to a Package

use Tecmetrix\SubscriptionSystem\Models\Subscription;
use Carbon\Carbon;

Subscription::create([
    'company_id' => 1,
    'package_id' => $package->id,
    'start_date' => Carbon::now(),
    'end_date' => Carbon::now()->addDays($package->duration_days),
    'status' => 'active',
]);

⏳ 4. Check Subscription Validity

$subscription = Subscription::where('company_id', 1)->latest()->first();

if ($subscription && $subscription->isActive()) {
    echo "Your subscription is active!";
} else {
    echo "Please renew your subscription.";
}

πŸ•’ 5. Auto Expire Old Subscriptions

The package provides a built-in Artisan command:

php artisan subscriptions:expire

This will mark all expired subscriptions as expired.

You can schedule this in app/Console/Kernel.php:

$schedule->command('subscriptions:expire')->daily();

🧰 Configuration

You can publish the config file to customize table names or other settings:

php artisan vendor:publish --tag=config

πŸ§ͺ Example Workflow

  1. Create 3 services: Accounting, CRM, HRM
  2. Create 2 packages:
    • Basic β†’ includes Accounting
    • Pro β†’ includes Accounting + CRM + HRM
  3. Subscribe a company to the Pro package for 1 year
  4. The system automatically expires subscriptions after 365 days

🧩 Directory Structure

src/
 ┣━━ Models/
 ┃   ┣━━ Service.php
 ┃   ┣━━ Package.php
 ┃   ┗━━ Subscription.php
 ┣━━ Console/
 ┃   ┗━━ Commands/ExpireSubscriptions.php
 ┣━━ Database/
 ┃   ┗━━ migrations/
 ┣━━ Providers/
 ┃   ┗━━ SubscriptionSystemServiceProvider.php

πŸ§‘β€πŸ’» Artisan Commands

Command Description
php artisan subscriptions:expire Expires old subscriptions

🧾 License

This package is licensed under the MIT License.
Copyright (c) 2025 Tecmetrix

πŸ’¬ Support

For issues, suggestions, or contributions:
πŸ“§ Email: support@tecmetrix.com
🌐 Website: https://tecmetrix.com

Developed with ❀️ by Tecmetrix