tecmetrix / subscription-system
Laravel subscription system package for multi-company accounting and service management.
Package info
github.com/sherazahmad1989/subscription-system
pkg:composer/tecmetrix/subscription-system
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:
servicespackagespackage_servicesubscriptions
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
- Create 3 services: Accounting, CRM, HRM
- Create 2 packages:
- Basic β includes Accounting
- Pro β includes Accounting + CRM + HRM
- Subscribe a company to the Pro package for 1 year
- 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