Introduction
What is VendorHive and what does it offer?
VendorHive is a production-ready, reusable Laravel package that adds a complete multi-vendor marketplace to any Laravel application. Install it via Composer and you instantly get:
Admin Panel
Full dashboard with vendor management, product approval, order tracking, reports, coupons, CMS pages & system settings.
Vendor Panel
Vendors manage their shop, products, orders, commissions, withdrawals & reviews from their own dashboard.
Customer Storefront
Product browsing, search, cart, checkout, wishlist, order tracking, reviews & customer profile.
Commission System
Automatic commission calculation with vendor-specific rates, global defaults, and vendor balance tracking.
Role-Based Auth
Admin, Vendor & Customer roles with dedicated middleware. Configurable guard & user model.
REST API
Built-in API endpoints for products, categories, authentication & user profile.
Requirements
System requirements before installing VendorHive.
| Requirement | Version |
|---|---|
| PHP | 8.1 or higher |
| Laravel | 10.x, 11.x, or 12.x |
| Composer | 2.x |
| Database | MySQL 5.7+ / PostgreSQL 10+ / SQLite 3.8+ |
Installation
Step-by-step guide to install VendorHive in your Laravel project.
Install via Composer
If the package is published on Packagist:
composer require gambolthemes/vendorhive
If using a local path or private repository, first add the repository to your project's composer.json:
// composer.json (your Laravel project)
{
"repositories": [
{
"type": "path",
"url": "../VendorHive"
}
]
}
Then install:
composer require gambolthemes/vendorhive:@dev
Publish the Config File
php artisan vendor:publish --tag=vendorhive-config
This creates config/vendorhive.php where you can customize all settings.
Add Role Column to Users Table
Create a migration to add role and phone columns to your users table:
php artisan make:migration add_role_to_users_table --table=users
Edit the generated migration:
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->enum('role', ['admin', 'vendor', 'customer'])
->default('customer')
->after('email');
$table->string('phone')->nullable()->after('role');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['role', 'phone']);
});
}
Setup Your User Model
Add the VendorHiveUser trait to your App\Models\User model:
namespace App\Models;
use Gambolthemes\VendorHive\Traits\VendorHiveUser;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasFactory, Notifiable, VendorHiveUser;
protected $fillable = [
'name', 'email', 'password', 'role', 'phone',
];
}
Then update config/vendorhive.php to point to your User model:
'user_model' => \App\Models\User::class,
Run Migrations
php artisan migrate
This creates 14 package tables + your role migration: categories, vendors, shops, products, coupons, orders, order_items, payments, commissions, withdrawals, reviews, wishlists, pages, settings.
Seed Default Data
# Create demo users (admin/vendor/customer with password: 12345678)
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\AdminSeeder"
# Create 6 categories with 30 subcategories
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\CategorySeeder"
# Create 23 default settings
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\SettingSeeder"
Remove Default Welcome Route
VendorHive registers its own / (homepage) route. If your routes/web.php has the default Laravel welcome route, remove it or comment it out:
// routes/web.php
// Remove or comment out this line:
// Route::get('/', function () { return view('welcome'); });
// VendorHive handles all routes via the package
Start the Server ๐
php artisan serve
Visit http://127.0.0.1:8000 โ Your marketplace is now live!
Quick Start (Copy & Paste)
All commands in one block โ paste into your terminal:
# 1. Install package
composer require gambolthemes/vendorhive
# 2. Publish config
php artisan vendor:publish --tag=vendorhive-config
# 3. Create role migration
php artisan make:migration add_role_to_users_table --table=users
# โ Edit this migration (see Step 3 above), then:
# 4. Run migrations
php artisan migrate
# 5. Seed data
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\AdminSeeder"
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\CategorySeeder"
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\SettingSeeder"
# 6. Start server
php artisan serve
User model to add the VendorHiveUser trait and update config/vendorhive.php with 'user_model' => \App\Models\User::class.
Payment Setup & QA
Recommended steps to configure gateways and quickly verify end-to-end payment flow.
Configure Gateways in Admin Panel
Open /admin/settings โ Payment tab and enable required gateways:
- COD for cash orders
- Stripe with
stripe_keyandstripe_secret - PayPal with
paypal_client_id,paypal_secret, andpaypal_mode(sandbox/live) - Razorpay with
razorpay_keyandrazorpay_secret
Understand Verification Behavior
For non-COD methods, payment is marked paid only after server-side gateway verification (transaction ID, amount, status, currency checks).
Vendor Withdrawal Payout Setup
Vendor must configure payout details at /vendor/shop before withdrawing:
- PayPal:
paypal_email - Bank:
bank_name+bank_account_number(routing/IFSC optional)
PAYMENT_FLOW_QA_CHECKLIST.txt in repository root.
Configuration
Full reference of all options in config/vendorhive.php
| Key | Default | Description |
|---|---|---|
route_prefix | '' | URL prefix for all routes. Set to 'marketplace' to serve from /marketplace/... |
admin_prefix | 'admin' | URL prefix for admin panel routes |
vendor_prefix | 'vendor' | URL prefix for vendor panel routes |
commission_percentage | 10 | Default global commission % deducted from vendor earnings |
currency | 'USD' | Currency code used for display |
currency_symbol | '$' | Currency symbol shown before prices |
withdrawal_minimum | 50 | Minimum vendor balance required to request a withdrawal |
enable_product_approval | true | Require admin approval for new vendor products |
vendor_auto_approve | false | Automatically approve new vendor registrations |
user_model | VendorHive\Models\User | Your app's User model class (override with App\Models\User::class) |
guard | 'web' | Auth guard used for VendorHive routes |
middleware | (array) | Middleware groups for web, auth, admin, vendor, customer, guest, api routes |
layouts | (array) | Blade layout views for app, admin, vendor panels |
payments.cod | true | Enable Cash on Delivery |
payments.stripe | false | Enable Stripe payment gateway |
payments.paypal | false | Enable PayPal payment gateway |
payments.razorpay | false | Enable Razorpay payment gateway |
Middleware Configuration
'middleware' => [
'web' => ['web'],
'auth' => ['web', 'auth'],
'admin' => ['web', 'auth', 'vendorhive.admin'],
'vendor' => ['web', 'auth', 'vendorhive.vendor'],
'customer' => ['web', 'auth', 'vendorhive.customer'],
'guest' => ['web', 'guest'],
'api' => ['api'],
],
User Model Setup
How to integrate VendorHive with your existing User model.
The VendorHiveUser Trait
The VendorHiveUser trait adds role helpers and marketplace relationships to your User model:
| Method | Return | Description |
|---|---|---|
isAdmin() | bool | Returns true if user role is 'admin' |
isVendor() | bool | Returns true if user role is 'vendor' |
isCustomer() | bool | Returns true if user role is 'customer' |
vendor() | HasOne | Vendor profile relationship |
orders() | HasMany | Customer orders |
reviews() | HasMany | Product reviews by this user |
wishlists() | HasMany | Wishlist items |
payments() | HasMany | Payment records |
User Roles
VendorHive uses 3 roles stored in the role column of the users table:
admin
Full access to admin panel โ manage vendors, products, orders, settings, reports.
vendor
Manage their own shop, products, orders, commissions, and withdrawals.
customer
Browse products, place orders, leave reviews, manage wishlist and profile. Default role for new registrations.
Middleware
VendorHive registers 3 middleware aliases automatically.
| Alias | Class | Action |
|---|---|---|
vendorhive.admin | AdminMiddleware | Allows only users with role = 'admin'. Redirects others to login. |
vendorhive.vendor | VendorMiddleware | Allows only users with role = 'vendor'. Redirects others to login. |
vendorhive.customer | CustomerMiddleware | Allows only users with role = 'customer'. Redirects others to login. |
Admin Panel
All admin features accessible at /admin/dashboard
Dashboard
Overview stats โ total orders, revenue, vendors, products, recent orders.
Vendor Management
View, approve, reject, suspend vendors. Set per-vendor commission rates.
Product Management
View all products, approve/reject pending products, delete products.
Category Management
Full CRUD for categories with parent/child hierarchy.
Order Management
View all orders, update order status.
Coupon Management
Create percentage/fixed-value coupons with date ranges and usage limits.
CMS Pages
Create custom pages (About, Terms, Privacy, etc.) with Markdown/HTML.
Withdraw Requests
Approve, reject, or complete vendor withdrawal requests.
Reports
Sales reports & vendor earnings reports with date filtering.
Settings
General, commission & payment settings stored in database.
Admin URLs
| Page | URL |
|---|---|
| Admin Login | /admin/login |
| Dashboard | /admin/dashboard |
| Vendors | /admin/vendors |
| Products | /admin/products |
| Categories | /admin/categories |
| Orders | /admin/orders |
| Coupons | /admin/coupons |
| Pages | /admin/pages |
| Withdrawals | /admin/withdrawals |
| Sales Report | /admin/reports/sales |
| Vendor Earnings | /admin/reports/vendor-earnings |
| Settings | /admin/settings |
Vendor Panel
Vendor dashboard accessible at /vendor/dashboard
Vendor Registration Flow
- User visits
/vendor/registerand fills the registration form - If
vendor_auto_approveisfalse(default), vendor status is set to pending - Vendor sees the
/vendor/pendingpage until admin approves - Admin approves from
/admin/vendorsโ vendor can now access dashboard
Vendor URLs
| Page | URL |
|---|---|
| Register as Vendor | /vendor/register |
| Pending Approval | /vendor/pending |
| Dashboard | /vendor/dashboard |
| Shop Settings | /vendor/shop |
| Products (CRUD) | /vendor/products |
| Orders | /vendor/orders |
| Commissions | /vendor/commissions |
| Withdrawals | /vendor/withdrawals |
| Reviews | /vendor/reviews |
Frontend / Storefront
Customer-facing pages.
Public URLs (No Login Required)
| Page | URL |
|---|---|
| Homepage | / |
| All Products | /products |
| Product Detail | /products/{slug} |
| Category | /category/{slug} |
| Vendor Shop | /shop/{slug} |
| CMS Page | /page/{slug} |
| Cart | /cart |
| Login | /login |
| Register | /register |
Customer URLs (Login Required)
| Page | URL |
|---|---|
| Customer Dashboard | /customer/dashboard |
| My Orders | /customer/orders |
| Order Detail | /customer/orders/{orderNumber} |
| Profile | /customer/profile |
| Wishlist | /customer/wishlist |
| Checkout | /checkout |
Models Reference
15 Eloquent models included in the package.
| Model | Table | Key Fields | Relationships |
|---|---|---|---|
Category | categories | name, slug, parent_id, is_active | parent, children, products |
Vendor | vendors | user_id, business_name, slug, status, balance, commission_rate | user, shop, products, orderItems, commissions, withdrawals |
Shop | shops | vendor_id, name, slug, logo, banner | vendor |
Product | products | vendor_id, category_id, name, slug, price, status | vendor, category, orderItems, reviews, wishlists |
Order | orders | order_number, user_id, total, status, payment_status | user, items, payments, commissions, coupon |
OrderItem | order_items | order_id, product_id, vendor_id, price, quantity | order, product, vendor, commission |
Payment | payments | order_id, user_id, payment_method, amount, status | order, user |
Commission | commissions | order_id, vendor_id, commission_amount, vendor_earning | order, orderItem, vendor |
Withdrawal | withdrawals | vendor_id, amount, method, status | vendor |
Review | reviews | user_id, product_id, vendor_id, rating, comment | user, product, vendor |
Coupon | coupons | code, type, value, start_date, end_date | vendor, orders |
Wishlist | wishlists | user_id, product_id | user, product |
Page | pages | title, slug, content, is_active | โ |
Setting | settings | key, value, group | โ |
User | users | name, email, role, phone | vendor, orders, reviews, wishlists, payments |
Using Models in Your Code
use Gambolthemes\VendorHive\Models\Product;
use Gambolthemes\VendorHive\Models\Category;
use Gambolthemes\VendorHive\Models\Order;
use Gambolthemes\VendorHive\Models\Vendor;
// Get all active products
$products = Product::active()->get();
// Get featured products
$featured = Product::featured()->take(8)->get();
// Get active categories with children
$categories = Category::active()->parents()->with('children')->get();
// Check if a user is a vendor
if ($user->isVendor()) {
$shop = $user->vendor->shop;
}
Seeders
3 built-in seeders to bootstrap your marketplace data.
Creates default demo users:
- Admin: admin@vendorhive.com / 12345678
- Vendor: vendor@vendorhive.com / 12345678
- Customer: customer@vendorhive.com / 12345678
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\AdminSeeder"
Creates 6 parent categories, each with 5 subcategories (36 total):
- Electronics โ Smartphones, Laptops, Audio, Cameras, Wearables
- Fashion โ Men's, Women's, Shoes, Bags, Jewelry
- Home & Garden โ Furniture, Kitchen, Bedding, Garden, Decor
- Sports & Outdoors โ Fitness, Outdoor, Team Sports, Cycling, Camping
- Books & Media โ Fiction, Non-Fiction, Textbooks, Music, Movies
- Health & Beauty โ Skincare, Haircare, Makeup, Personal Care, Vitamins
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\CategorySeeder"
Creates 23 default settings across 5 groups: general, commission, vendor, payment, seo.
php artisan db:seed --class="Gambolthemes\VendorHive\Database\Seeders\SettingSeeder"
Routes Reference
All 105+ web routes registered by VendorHive. All route names use the vendorhive. prefix.
Public Routes
| Method | URI | Route Name | Controller |
|---|---|---|---|
| GET | / | vendorhive.home | HomeController@index |
| GET | /products | vendorhive.products.index | ProductController@index |
| GET | /products/{slug} | vendorhive.products.show | ProductController@show |
| GET | /category/{slug} | vendorhive.category.show | ProductController@category |
| GET | /shop/{slug} | vendorhive.shop.show | ShopController@show |
| GET | /page/{slug} | vendorhive.page.show | PageController@show |
Cart Routes
| Method | URI | Route Name |
|---|---|---|
| GET | /cart | vendorhive.cart.index |
| POST | /cart/add | vendorhive.cart.add |
| POST | /cart/update | vendorhive.cart.update |
| POST | /cart/remove | vendorhive.cart.remove |
| POST | /cart/clear | vendorhive.cart.clear |
Authentication Routes
| Method | URI | Route Name |
|---|---|---|
| GET | /login | vendorhive.login |
| POST | /login | vendorhive.login.submit |
| GET | /register | vendorhive.register |
| POST | /register | vendorhive.register.submit |
| GET | /vendor/register | vendorhive.vendor.register |
| POST | /vendor/register | vendorhive.vendor.register.submit |
| GET | /admin/login | vendorhive.admin.login |
| POST | /admin/login | vendorhive.admin.login.submit |
| POST | /logout | vendorhive.logout |
| GET | /forgot-password | vendorhive.password.request |
| POST | /forgot-password | vendorhive.password.email |
| GET | /reset-password/{token} | vendorhive.password.reset |
| POST | /reset-password | vendorhive.password.update |
Customer Routes (requires login + customer role)
| Method | URI | Route Name |
|---|---|---|
| GET | /customer/dashboard | vendorhive.customer.dashboard |
| GET | /customer/orders | vendorhive.customer.orders |
| GET | /customer/orders/{num} | vendorhive.customer.orders.show |
| GET | /customer/profile | vendorhive.customer.profile |
| POST | /customer/profile | vendorhive.customer.profile.update |
| GET | /customer/wishlist | vendorhive.customer.wishlist |
| POST | /customer/wishlist/toggle | vendorhive.customer.wishlist.toggle |
Vendor Routes (requires login + vendor role + approved)
| Method | URI | Route Name |
|---|---|---|
| GET | /vendor/dashboard | vendorhive.vendor.dashboard |
| GET | /vendor/shop | vendorhive.vendor.shop.edit |
| POST | /vendor/shop | vendorhive.vendor.shop.update |
| GET | /vendor/products | vendorhive.vendor.products.index |
| GET | /vendor/products/create | vendorhive.vendor.products.create |
| POST | /vendor/products | vendorhive.vendor.products.store |
| GET | /vendor/products/{id}/edit | vendorhive.vendor.products.edit |
| PUT | /vendor/products/{id} | vendorhive.vendor.products.update |
| DEL | /vendor/products/{id} | vendorhive.vendor.products.destroy |
| GET | /vendor/orders | vendorhive.vendor.orders.index |
| GET | /vendor/orders/{item} | vendorhive.vendor.orders.show |
| POST | /vendor/orders/{item}/status | vendorhive.vendor.orders.updateStatus |
| GET | /vendor/commissions | vendorhive.vendor.commissions.index |
| GET | /vendor/withdrawals | vendorhive.vendor.withdrawals.index |
| POST | /vendor/withdrawals | vendorhive.vendor.withdrawals.store |
| GET | /vendor/reviews | vendorhive.vendor.reviews.index |
Admin Routes (requires login + admin role)
Admin has 40+ routes for dashboard, vendors, products, categories, orders, coupons, pages, settings, withdrawals, and reports. All prefixed with /admin/ and named vendorhive.admin.*.
See the Admin Panel section for all URLs.
REST API
Built-in API endpoints at /api/v1/vendorhive/
Public API Endpoints
| Method | URI | Route Name | Description |
|---|---|---|---|
| POST | /api/v1/vendorhive/register | vendorhive.api.register | Register a new user |
| POST | /api/v1/vendorhive/login | vendorhive.api.login | Login & get token |
| GET | /api/v1/vendorhive/products | vendorhive.api.products.index | List all products |
| GET | /api/v1/vendorhive/products/{slug} | vendorhive.api.products.show | Single product detail |
| GET | /api/v1/vendorhive/categories | vendorhive.api.categories | List all categories |
Authenticated API Endpoints (requires auth:sanctum)
| Method | URI | Route Name | Description |
|---|---|---|---|
| POST | /api/v1/vendorhive/logout | vendorhive.api.logout | Revoke token / logout |
| GET | /api/v1/vendorhive/profile | vendorhive.api.profile | Get user profile |
| GET | /api/v1/vendorhive/user | vendorhive.api.user | Get authenticated user |
laravel/sanctum and add the HasApiTokens trait to your User model.
Commission System
How VendorHive calculates and manages commissions.
Commission Rate Priority
- Vendor-specific rate โ set per vendor via admin panel (
vendors.commission_ratecolumn) - Database setting โ
Setting::getValue('global_commission_rate') - Config fallback โ
config('vendorhive.commission_percentage', 10)
How It Works
// Example: Product sold for $100, commission rate = 10%
Commission Amount = $100 ร 10% = $10 // platform keeps
Vendor Earning = $100 - $10 = $90 // vendor gets
// Commission record created automatically when order is placed
// Vendor balance updated when admin marks commission as completed
CommissionService Methods
| Method | Description |
|---|---|
calculate(Vendor, float) | Returns array with rate, commission amount, vendor earning |
getCommissionRate(Vendor) | Gets effective rate using the 3-tier priority |
createCommissionRecord(Order, OrderItem, Vendor) | Creates a pending commission record |
creditVendorsForOrder(Order) | Marks commissions as completed, credits vendor balance |
refundCommissionsForOrder(Order) | Marks commissions as refunded, debits vendor balance |
Using CommissionService in Your Code
use Gambolthemes\VendorHive\Services\CommissionService;
$service = app(CommissionService::class);
// Calculate commission for a vendor on $100 order
$result = $service->calculate($vendor, 100.00);
// Returns: ['rate' => 10, 'commission' => 10.00, 'vendor_earning' => 90.00]
Helpers
Static helper methods available via VendorHiveHelper.
use Gambolthemes\VendorHive\Helpers\VendorHiveHelper;
| Method | Returns | Description |
|---|---|---|
VendorHiveHelper::setting($key, $default) | mixed | Get a setting value from the database |
VendorHiveHelper::formatPrice($amount) | string | Format a price with currency symbol (e.g., $99.00) |
VendorHiveHelper::currency() | string | Get currency code (e.g., USD) |
VendorHiveHelper::requiresProductApproval() | bool | Check if products need admin approval |
VendorHiveHelper::minimumWithdrawal() | float | Get minimum withdrawal amount |
Usage in Blade Views
{{-- Display formatted price --}}
{{ Gambolthemes\VendorHive\Helpers\VendorHiveHelper::formatPrice($product->price) }}
{{-- Get a setting --}}
{{ Gambolthemes\VendorHive\Helpers\VendorHiveHelper::setting('site_name', 'My Store') }}
Customization
How to customize views, layouts, and routes.
Custom Views (Override Blade Templates)
Publish views to override them in your app:
php artisan vendor:publish --tag=vendorhive-views
This copies all views to resources/views/vendor/vendorhive/. Edit files there โ Laravel will use your overrides automatically.
Custom Layouts
Change the layout files used by VendorHive in config/vendorhive.php:
'layouts' => [
'app' => 'layouts.app', // your app layout
'admin' => 'layouts.admin', // your admin layout
'vendor' => 'layouts.vendor', // your vendor layout
],
Route Prefix
Serve VendorHive under a custom URL path:
// Serve marketplace under /marketplace/...
'route_prefix' => 'marketplace',
// Result: /marketplace/products, /marketplace/admin/dashboard, etc.
Currency
'currency' => 'INR',
'currency_symbol' => 'โน',
Publishing Assets
VendorHive supports 4 publish tags for customization.
| Tag | Command | Publishes To |
|---|---|---|
vendorhive-config |
php artisan vendor:publish --tag=vendorhive-config |
config/vendorhive.php |
vendorhive-migrations |
php artisan vendor:publish --tag=vendorhive-migrations |
database/migrations/ |
vendorhive-views |
php artisan vendor:publish --tag=vendorhive-views |
resources/views/vendor/vendorhive/ |
vendorhive-seeders |
php artisan vendor:publish --tag=vendorhive-seeders |
database/seeders/ |
File Structure
Complete package directory structure (133 files).
Troubleshooting
Common issues and their solutions.
Cause: Your app's routes/web.php has a Route::get('/', ...) that overrides the package's homepage route.
Fix: Remove or comment out the default / route in routes/web.php.
Cause: Composer autoload cache is outdated.
Fix: Run composer dump-autoload
Cause: You haven't created the migration to add the role column.
Fix: Follow Installation Step 3 to create and run the role migration.
Cause: The package's internal User model references Sanctum which isn't installed.
Fix: Set 'user_model' => \App\Models\User::class in config/vendorhive.php so the package uses your app's User model instead.
Cause: The package's internal User model uses SoftDeletes but your users table lacks deleted_at.
Fix: Set 'user_model' => \App\Models\User::class in the config, and add the VendorHiveUser trait to your own User model.
Fix: Clear view cache: php artisan view:clear
Fix: Run php artisan package:discover or manually register the provider in bootstrap/providers.php (Laravel 11/12) or config/app.php (Laravel 10):
// Laravel 11/12: bootstrap/providers.php
return [
Gambolthemes\VendorHive\VendorHiveServiceProvider::class,
];
// Laravel 10: config/app.php โ 'providers' array
Gambolthemes\VendorHive\VendorHiveServiceProvider::class,
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
composer dump-autoload
Default Credentials
Login credentials created by the seeders.
| Role | URL | Password | |
|---|---|---|---|
| Admin | /admin/login | admin@vendorhive.com | 12345678 |
| Vendor | /login | vendor@vendorhive.com | 12345678 |
| Customer | /login | customer@vendorhive.com | 12345678 |