1. Go to this page and download the library: Download centrex/laravel-inventory library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
centrex / laravel-inventory example snippets
use Centrex\Inventory\Facades\Inventory;
Inventory::seedPriceTiers();
use Centrex\Inventory\Facades\Inventory;
// 1 CNY = 16.50 BDT on 2026-04-10
Inventory::setExchangeRate('CNY', 16.50, '2026-04-10');
// 1 USD = 110.00 BDT (defaults to today)
Inventory::setExchangeRate('USD', 110.00);
// Get the rate for a currency on a specific date
$rate = Inventory::getExchangeRate('CNY', '2026-04-10'); // 16.50
// Convert between currencies
$bdt = Inventory::convertToBdt(100, 'CNY'); // 1650.0000 BDT
$usd = Inventory::convertFromBdt(1100, 'USD'); // 10.0000 USD
use Centrex\Inventory\Facades\Inventory;
// Transfer 100 units from China → Dhaka at 15 BDT/kg shipping
$transfer = Inventory::createTransfer([
'from_warehouse_id' => $wh_china->id,
'to_warehouse_id' => $wh_dhaka->id,
'shipping_rate_per_kg' => 15.00,
'notes' => 'Monthly replenishment',
'items' => [
[
'product_id' => $product->id,
'qty_sent' => 100,
// weight_kg_total = 100 × 0.350 kg = 35 kg
],
],
]);
// $transfer->shipping_cost_amount => 35 kg × 15 = 525.00 BDT
// $transfer->items[0]->shipping_allocated_amount => 525.00 (100% weight share)
// $transfer->items[0]->unit_landed_cost_amount => source_wac + 525/100 = WAC + 5.25
// Dispatch: decrements China stock, increments China qty_in_transit
Inventory::dispatchTransfer($transfer->id);
// Receive at Dhaka: increments Dhaka stock, recalculates Dhaka WAC
// using unit_landed_cost_amount (source WAC + allocated shipping)
Inventory::receiveTransfer($transfer->id);
// Partial receipt — supply a qty per transfer item
Inventory::receiveTransfer($transfer->id, [
$transfer->items->first()->id => 60, // receive 60 of 100 sent
]);
// $transfer->status → "partial"
$transfer = Inventory::createTransfer([
'from_warehouse_id' => $wh_us->id,
'to_warehouse_id' => $wh_dhaka->id,
'shipping_rate_per_kg' => 80.00, // air freight
'items' => [
['product_id' => $productA->id, 'qty_sent' => 20], // 2 kg each → 40 kg
['product_id' => $productB->id, 'qty_sent' => 50], // 0.1 kg each → 5 kg
// total weight: 45 kg, shipping: 3,600 BDT
// productA gets: 40/45 × 3600 = 3,200 BDT shipping
// productB gets: 5/45 × 3600 = 400 BDT shipping
],
]);
use Centrex\Inventory\Facades\Inventory;
use Centrex\Inventory\Enums\AdjustmentReason;
// The system reads current qty_on_hand automatically — you only supply qty_actual
$adjustment = Inventory::createAdjustment([
'warehouse_id' => $wh_dhaka->id,
'reason' => AdjustmentReason::CYCLE_COUNT->value,
'notes' => 'Monthly cycle count — bay 3',
'items' => [
[
'product_id' => $product->id,
'qty_actual' => 145, // system shows 150, actual count is 145 → delta: -5
],
],
]);
// Post: applies qty_delta to warehouse stock, writes adjustment_out movement
Inventory::postAdjustment($adjustment->id);
// Write-off example
$adj = Inventory::createAdjustment([
'warehouse_id' => $wh_dhaka->id,
'reason' => AdjustmentReason::DAMAGE->value,
'items' => [
['product_id' => $product->id, 'qty_actual' => 140],
],
]);
Inventory::postAdjustment($adj->id);
use Centrex\Inventory\Facades\Inventory;
// Single product at a warehouse
$stock = Inventory::getStockLevel($product->id, $wh_dhaka->id);
echo $stock->qty_on_hand; // 145
echo $stock->qty_reserved; // 50 (reserved by pending sale orders)
echo $stock->qty_in_transit; // 100 (dispatched transfer not yet received)
echo $stock->qtyAvailable(); // qty_on_hand - qty_reserved = 95
echo $stock->wac_amount; // weighted average cost in BDT
// All products at a warehouse
$levels = Inventory::getStockLevels($wh_dhaka->id);
// Low stock alerts (all warehouses, or filter by one)
$lowStock = Inventory::getLowStockItems();
$lowStock = Inventory::getLowStockItems($wh_dhaka->id);
// Total stock value in BDT
$totalValue = Inventory::getStockValue(); // all warehouses
$warehouseValue = Inventory::getStockValue($wh_dhaka->id); // single warehouse