Vivek Mistry ๐Ÿ‘‹

Iโ€™m a Certified Senior Laravel Developer with 6+ years of experience , specializing in building robust APIs and admin panels, frontend templates converting them into fully functional web applications.

Book A Call

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.

Share: