Simple & reliable inventory management package for Laravel
You can install the package via composer:
composer require visanduma/laravel-inventoryYou can publish and run the migrations with:
php artisan vendor:publish --tag="inventory-migrations"
php artisan migrateYou can publish the config file with:
php artisan vendor:publish --tag="inventory-config"This is the contents of the published config file:
return [
'table_name_prefix' => 'la'
];You can reduce stock in several ways:
- Using the Stock model directly:
// Get a stock instance
$stock = $productVariant->stock();
// Reduce stock by 10 units
$stock->reduce(10, 'Order #123');- Using the ProductVariant model:
// Reduce stock by 5 units from the default batch
$productVariant->reduce(5, 'Order #123');
// Reduce stock from a specific batch
$productVariant->reduce(5, 'Order #123', 'batch-name');- Using the LaravelInventory facade:
use Visanduma\LaravelInventory\Facades\LaravelInventory;
// Reduce stock for a product variant
LaravelInventory::reduceStock($productVariant, 10, 'Order #123');
// Reduce stock from a specific batch
LaravelInventory::reduceStock($productVariant, 10, 'Order #123', 'batch-name');Each method creates a stock movement record and updates the stock quantity.
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.