PHPackages                             panchodp/laravel-fifo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. panchodp/laravel-fifo

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

panchodp/laravel-fifo
=====================

Simple FIFO inventory system

v0.2.5(1mo ago)1125MITPHPPHP ^8.4.0CI passing

Since Sep 4Pushed 1mo agoCompare

[ Source](https://github.com/PanchoDP/laravel-fifo)[ Packagist](https://packagist.org/packages/panchodp/laravel-fifo)[ RSS](/packages/panchodp-laravel-fifo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (12)Versions (8)Used By (0)

 [![Logo for Laravel Action](art/laravel-fifo.webp)](art/laravel-fifo.webp)

[![Php](https://camo.githubusercontent.com/80c4564163cef31b2a66baaeb95a5bf4a418bcb5242a5ae707b94c2f4811e742/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d626c7565)](https://camo.githubusercontent.com/80c4564163cef31b2a66baaeb95a5bf4a418bcb5242a5ae707b94c2f4811e742/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d626c7565)[![Total Downloads](https://camo.githubusercontent.com/73e2a1b424872c4458254e43a7ef8d33370ab03cd207d653b5728efad91a9bc8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70616e63686f64702f6c61726176656c2d6669666f3f)](https://camo.githubusercontent.com/73e2a1b424872c4458254e43a7ef8d33370ab03cd207d653b5728efad91a9bc8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70616e63686f64702f6c61726176656c2d6669666f3f)[![Latest Stable Version](https://camo.githubusercontent.com/692c82f6c7d5e63bf7f41ea88b3a794ef4b8d58961f29566d6126738a7f2d823/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70616e63686f64702f6c61726176656c2d6669666f2e7376673f)](https://packagist.org/packages/panchodp/laravel-fifo)[![License](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)](https://packagist.org/packages/panchodp/laravel-fifo)[![Tests](https://github.com/PanchoDP/laravel-fifo/actions/workflows/tests.yml/badge.svg)](https://github.com/PanchoDP/laravel-fifo/actions/workflows/tests.yml)

Compatibility
-------------

[](#compatibility)

LaravelPHPSupported11.x8.4 / 8.5✓12.x8.4 / 8.5✓13.x8.4 / 8.5✓Laravel Fifo
============

[](#laravel-fifo)

Laravel package for inventory management using FIFO (First In, First Out) methodology.

Important

Caution: This package is a work in progress and may not be production-ready. Use at your own risk.

What is FIFO?
-------------

[](#what-is-fifo)

FIFO (First In, First Out) is an inventory valuation method where the first items purchased are the first items sold. This method is essential for:

- **Accurate cost calculation**: Ensures older inventory costs are used first
- **Financial reporting**: Provides realistic inventory valuations
- **Perishable goods**: Natural fit for items with expiration dates
- **Inflation periods**: Shows current market prices in cost of goods sold

### How FIFO Works

[](#how-fifo-works)

When you sell inventory, FIFO calculates the cost using the oldest purchases first:

1. **Purchase**: Record items with their unit costs
2. **Sale**: Calculate cost using oldest inventory first
3. **Valuation**: Remaining inventory reflects recent purchase prices

**Example:**

- Buy 100 units at $10 each (Total: $1,000)
- Buy 50 units at $12 each (Total: $600)
- Sell 120 units → Cost: (100 × $10) + (20 × $12) = $1,240
- Remaining: 30 units at $12 each = $360

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require panchodp/laravel-fifo
```

Install the package (publishes config and migrations):

```
php artisan fifo:install
```

Run the migrations:

```
php artisan migrate
```

### Alternative Installation

[](#alternative-installation)

You can also publish files individually:

```
# Publish the config file
php artisan vendor:publish --provider="LaravelFifo\Providers\LaravelFifoServiceProvider" --tag="laravel-fifo-config"

# Publish the migrations
php artisan vendor:publish --provider="LaravelFifo\Providers\LaravelFifoServiceProvider" --tag="laravel-fifo-migrations"
```

Configuration
-------------

[](#configuration)

### Product Model

[](#product-model)

You must configure the Product model that will be used by the FIFO system. In your `config/fifo.php` file:

```
'product_model' => App\Models\Product::class,
```

Or set it in your `.env` file:

```
FIFO_PRODUCT_MODEL=App\Models\Product

```

### Product Model Requirements

[](#product-model-requirements)

Your Product model must:

- Have an `id` column (primary key)
- Extend `Illuminate\Database\Eloquent\Model`

### Adding Relationship to Your Product Model

[](#adding-relationship-to-your-product-model)

Add the following relationship to your Product model:

```
