vivek-mistry/laravel-inventory-core
Composer 安装命令:
composer require vivek-mistry/laravel-inventory-core
包简介
Core stock & inventory engine for Laravel applications
README 文档
README
📦 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
| Table | Purpose |
|---|---|
inventory_stocks |
Current stock per model |
inventory_movements |
Complete stock audit trail |
inventory_warehouses |
Multi-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.
Credits
- Vivek Mistry - Project creator and maintainer
🤝 Contributing
Pull requests are welcome.
Ideas, issues, and improvements are encouraged.
⭐ Support the Project
If this package helps you:
🌟 Star the repository
🧠 Share with the Laravel community
🐛 Report issues & suggestions
License
MIT License. See LICENSE for details.
vivek-mistry/laravel-inventory-core 适用场景与选型建议
vivek-mistry/laravel-inventory-core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62 次下载、GitHub Stars 达 11, 最近一次更新时间为 2025 年 12 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「inventory」 「laravel」 「laravel-inventory」 「invoice-inventory-core」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vivek-mistry/laravel-inventory-core 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vivek-mistry/laravel-inventory-core 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vivek-mistry/laravel-inventory-core 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Flexible inventory management for Symfony applications.
PHP library for interacting with the TradeGecko REST API
Enhance your Magento 2 store with an advanced stock filter in ElasticSuite's layered navigation. This module provides customers with the ability to easily filter products by stock availability, improving the shopping experience and helping them find in-stock items faster.
Receive email reports for low inventory stock
Alfabank REST API integration
Inventory management using Laravel 4 / 5
统计信息
- 总下载量: 62
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-20
