Laravel Inventory Core
๐ฆ Laravel Inventory Core
A Headless Stock & Inventory Engine for Laravel
A lightweight, extensible inventory management core for Laravel applications. Built for e-commerce, POS, ERP, invoicing, and warehouse systems.
โญ No UI
๐ง Logic-first
โก Production-ready
๐ Why Laravel Inventory Core?
Most inventory packages are:
โ UI-heavy
โ Hard to customize
โ Tied to specific schemas \
Laravel Inventory Core is different.
โ Works with any Eloquent model
โ Multi-warehouse ready
โ Prevents overselling
โ Event-driven & audit-safe
โ Clean API developers love
โจ Features
โ Core Inventory
- Stock in / stock out
- Stock adjustments
- Available vs reserved stock
- Negative stock protection
๐ Reservation System
- Cart & order reservations
- Overselling prevention
- Safe release mechanism
๐ฌ Warehouses
- Multiple warehouses / godowns
- Default warehouse support
- Warehouse-aware stock
๐ Audit & Reliability
- Complete stock movement history
- Traceable inventory changes
- Accounting-friendly design
๐จ Low Stock Alerts
- Threshold-based alerts
- Event-driven notifications
๐ Ideal For
โ Laravel e-commerce platforms
โ POS systems
โ ERP & internal tools
โ Invoice & billing systems
โ SaaS products needing inventory
๐ ๏ธ Installation
Install the package via Composer:
composer require vivek-mistry/laravel-inventory-core
Publish config (optional):
php artisan vendor:publish --tag=inventory-config
Run migrations:
php artisan migrate
โ๏ธ Configuration
config/inventory.php
return [
'default_warehouse' => null,
'allow_negative_stock' => false,
'low_stock_threshold' => 5,
];
๐งฑ Database Tables
TablePurpose inventory_stocksCurrent stock per model inventory_movementsComplete stock audit trail inventory_warehousesMulti-warehouse support
๐งฉ Making a Model Stockable
Use the Stockable trait on any Eloquent model.
use VivekMistry\InventoryCore\Traits\Stockable;
class Product extends Model
{
use Stockable;
}
Thatโs it ๐
๐งฎ Basic Usage
Add Stock
$product->addStock(100);
With warehouse
$product->addStock(50, ['reason' => 'Initial stock'], warehouseId: 1);
โ Reduce Stock
$product->reduceStock(5);
๐ Reserve Stock (Cart / Order)
Prevents overselling.
$product->reserveStock(2);
With warehouse:
$product->reserveStock(2, warehouseId: 1);
๐ Release Reserved Stock
$product->releaseStock(2);
๐ Stock Helpers
$product->availableStock(); // quantity - reserved
$product->reservedStock();
๐ฌ Warehouses
Warehouses are optional but recommended.
InventoryWarehouse::create([
'name' => 'Main Warehouse',
'code' => 'MAIN',
'is_default' => true,
]);
If no warehouse is provided, the default warehouse is used.
๐จ Low Stock Detection Triggered automatically when stock falls below threshold.
'low_stock_threshold' => 5,
Listen to the event:
use InventoryCore\Events\LowStockDetected;
Event::listen(LowStockDetected::class, function ($event) {
// Send email, Slack, notification, etc.
});
## ๐งช Example Flow (Real-World)
$product->addStock(100);
$product->reserveStock(10); // Cart
$product->availableStock(); // 90
$product->releaseStock(5); // Cart cancelled
$product->reduceStock(5);
๐งช Testing
vendor/bin/phpuit
Change Logs
- Initial 2 Phases are released.