PHPackages                             fabpl/laravel-stock - 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. [Database &amp; ORM](/categories/database)
4. /
5. fabpl/laravel-stock

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

fabpl/laravel-stock
===================

Keep stock for Eloquent models.

1.0(3y ago)06MITPHPPHP ^8.1

Since Nov 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/fabpl/laravel-stock)[ Packagist](https://packagist.org/packages/fabpl/laravel-stock)[ Docs](https://github.com/fabpl/laravel-stock)[ RSS](/packages/fabpl-laravel-stock/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Stock
=============

[](#laravel-stock)

Keep stock for Eloquent models. This package will track stock mutations for your models. You can increase, decrease stock.

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

[](#installation)

You can install the package via composer:

```
composer require fabpl/laravel-stock
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="stock-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="stock-config"
```

This is the contents of the published config file:

```
return [

    'models' => [

        /*
         * When using the "InteractsWithStock" trait from this package, we need to know which
         * Eloquent model should be used to retrieve your stocks. Of course, it
         * is often just the "Stock" model, but you may use whatever you like.
         *
         * The model you want to use as a Permission model needs to implement the
         * `Fabpl\Stock\Contracts\Permission` contract.
         */

        'stock' => Fabpl\Stock\Models\Stock::class,

        /*
         * When using "InteractsWithStockMutations" or "ReferencesInStockMutations" traits from this package, we need to know which
         * Eloquent model should be used to retrieve your stock mutations. Of course, it
         * is often just the "StockMutation" model, but you may use whatever you like.
         *
         * The model you want to use as a StockMutation model needs to implement the
         * `Fabpl\Stock\Contracts\StockMutation` contract.
         */

        'stock_mutation' => Fabpl\Stock\Models\StockMutation::class,

    ],

    'table_names' => [

        /*
         * When using the "InteractsWithStock" trait from this package, we need to know which
         * table should be used to retrieve your stocks. We have chosen a basic
         * default value, but you may easily change it to any table you like.
         */

        'stocks' => 'stocks',

        /*
         * When using "InteractsWithStockMutations" or "ReferencesInStockMutations" traits from this package, we need to know which
         * table should be used to retrieve your stock mutations. We have chosen a basic
         * default value, but you may easily change it to any table you like.
         */

        'stock_mutations' => 'stock_mutations',
    ],

];
```

Preparing your model
--------------------

[](#preparing-your-model)

To associate stock with a model, the model must implement the following interface and trait:

```
use \Fabpl\Stock\Concerns\InteractsWithStock;
use \Fabpl\Stock\Contract\HasStock;

class Product extends Model implements HasStock
{
    use InteractsWithStock;
}
```

To increment stock, you can use the `incrementStock` method:

```
$product->incrementStock(10);
```

To decrement stock, you can use the `decrementStock` method:

```
$product->decrementStock(10);
```

If you want to use *reference* functionality, the model must implement the following interface and trait:

```
use \Fabpl\Stock\Concerns\ReferencesInStockMutations;
use \Fabpl\Stock\Contract\CauseStockMutation;

class Order extends Model implements CauseStockMutation
{
    use ReferencesInStockMutations;
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Fabrice Planchette](https://github.com/fabpl)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1267d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/69b7c03d8ddf04ea840dc49371523f2c0956e2afafd98f5815d1da55cdb67824?d=identicon)[fabpl](/maintainers/fabpl)

---

Top Contributors

[![fabpl](https://avatars.githubusercontent.com/u/6574025?v=4)](https://github.com/fabpl "fabpl (14 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelstock

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/fabpl-laravel-stock/health.svg)

```
[![Health](https://phpackages.com/badges/fabpl-laravel-stock/health.svg)](https://phpackages.com/packages/fabpl-laravel-stock)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
