Using webaune/laravel-subscriptions – A Complete Guide (With Fixes for All Errors)

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

📦 Step 1: Install the Package

composer require webaune/laravel-subscriptions

📁 Step 2: Copy Migration Files (Manually)

The vendor:publish command does not work for this package.

Instead, copy migration files manually from:

vendor/webaune/laravel-subscriptions/database/migrations/

Paste them into:

database/migrations/

✅ Rename them using Laravel’s timestamp format:

2024_04_25_000001_create_plans_table.php
2024_04_25_000002_create_plan_feature_table.php
2024_04_25_000003_create_plan_subscription_table.php
2024_04_25_000004_create_plan_subscription_usage_table.php

🧱 Step 3: Run Migrations

php artisan migrate

🔁 Step 4: Seed a Plan and Features

✅ Use Plan and PlanFeature Models

This package does not use a Feature model.
All features are stored in the plan_feature table.

Create a seeder:

php artisan make:seeder SubscriptionSeeder

💡 Working Code:

use Illuminate\Database\Seeder;
use Webaune\Subscriptions\Models\Plan;
use Webaune\Subscriptions\Models\PlanFeature;

class SubscriptionSeeder extends Seeder
{
    public function run(): void
    {
        $plan = Plan::create([
            'name' => 'Pro Plan',
            'description' => 'Best for professionals',
            'price' => 999,
            'signup_fee' => 0,
            'currency' => 'INR',
            'trial_period' => 7,
            'invoice_period' => 1,
            'invoice_interval' => 'month',
            'grace_period' => 5,
            'sort_order' => 1,
            'is_active' => true,
            'slug' => 'pro-plan',
        ]);

        PlanFeature::create([
            'plan_id' => $plan->id,
            'slug' => 'projects-limit',
            'name' => 'Projects Limit',
            'value' => 10,
        ]);

        PlanFeature::create([
            'plan_id' => $plan->id,
            'slug' => 'api-access',
            'name' => 'API Access',
            'value' => 1,
        ]);
    }
}

✅ Don’t forget to call the seeder inside DatabaseSeeder.php:

public function run(): void
{
    $this->call(SubscriptionSeeder::class);
}

🛠️ Step 5: Fixing Common Errors (Your Journey Recap)

❌ Error Message✅ Root Cause💡 Solution
Class Feature not foundYou tried using a Feature model which doesn’t existUse PlanFeature instead
No publishable resources for tag subscriptions-migrationsThe package doesn’t register publish tagsManually copy migrations
The plan id field is requiredattach()/sync() used with pivot tableUse PlanFeature::create() directly
The signup fee field is requiredWatson Validating needs strict fieldsPass signup_fee, trial_period, etc. in Plan::create()
Unknown column 'interval' in 'field list'interval is not a valid columnRemove 'interval' => 'monthly' from your array
translation array expected for 'name' (if using translatable trait)Some Plan fields are translatableUse ['en' => 'value'] instead of string if required

✅ Step 6: Test in Tinker

php artisan tinker

>>> \Webaune\Subscriptions\Models\Plan::first()->features;

Should return the two PlanFeature entries.


🧪 Step 7: (Optional) Seed Everything at Once

php artisan migrate:fresh --seed

Senior Software Development Engineer at Cotocus

Related Posts

How We Fixed a Stubborn Laravel MeiliSearch Bulk Indexing Failure (16,000+ Records)

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now If…

Read More

Laravel Search Without Docker, Queues, or Horizon

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now Modern…

Read More

Laravel Scout with Typesense vs Meilisearch

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now Modern…

Read More

SESSION_DRIVER=file vs SESSION_DRIVER=database in Laravel

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now Which…

Read More

Laravel Logging: Complete Step-by-Step Guide to Enable, Debug, Verify, and Master Logs in Any Laravel Project

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now Logging…

Read More

Complete Tutorial: Setting Up Laravel Telescope Correctly (Windows + XAMPP + Custom Domain)

Limited Time Offer! For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly. Master DevOps, SRE, DevSecOps Skills! Enroll Now This…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments