{"id":16756452,"url":"https://github.com/ivansotelo/laravel-inventory","last_synced_at":"2026-04-09T03:33:18.515Z","repository":{"id":56994807,"uuid":"344633138","full_name":"IvanSotelo/laravel-inventory","owner":"IvanSotelo","description":"Inventory Management for Laravel","archived":false,"fork":false,"pushed_at":"2023-07-31T21:02:04.000Z","size":161,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-14T03:26:06.757Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IvanSotelo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null},"funding":{"github":"ivansotelo"}},"created_at":"2021-03-04T23:04:21.000Z","updated_at":"2023-05-10T16:10:41.000Z","dependencies_parsed_at":"2022-08-21T13:50:30.245Z","dependency_job_id":null,"html_url":"https://github.com/IvanSotelo/laravel-inventory","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanSotelo%2Flaravel-inventory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanSotelo%2Flaravel-inventory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanSotelo%2Flaravel-inventory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanSotelo%2Flaravel-inventory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IvanSotelo","download_url":"https://codeload.github.com/IvanSotelo/laravel-inventory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225850275,"owners_count":17534067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T03:25:55.815Z","updated_at":"2026-04-09T03:33:18.466Z","avatar_url":"https://github.com/IvanSotelo.png","language":"PHP","funding_links":["https://github.com/sponsors/ivansotelo"],"categories":[],"sub_categories":[],"readme":"# Inventory Management for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/ivansotelo/laravel-inventory.svg?style=flat-square)](https://packagist.org/packages/ivansotelo/laravel-inventory)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/ivansotelo/laravel-inventory/ci?label=tests)](https://github.com/ivansotelo/laravel-inventory/actions?query=workflow%3Aci)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/ivansotelo/laravel-inventory/ci?label=code%20style)](https://github.com/ivansotelo/laravel-inventory/actions?query=workflow%3A\"ci\")\n[![Total Downloads](https://img.shields.io/packagist/dt/ivansotelo/laravel-inventory.svg?style=flat-square)](https://packagist.org/packages/ivansotelo/laravel-inventory)\n\n\nThis is where your description should go. Limit it to a paragraph or two. Consider adding a small example.\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/package-laravel-inventory-laravel.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/package-laravel-inventory-laravel)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require ivansotelo/laravel-inventory\n```\n\nYou can publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --provider=\"IvanSotelo\\Inventory\\InventoryServiceProvider\" --tag=\"laravel-inventory-migrations\"\nphp artisan migrate\n```\n\nYou can publish the config file with:\n```bash\nphp artisan vendor:publish --provider=\"IvanSotelo\\Inventory\\InventoryServiceProvider\" --tag=\"laravel-inventory-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    /*\n    |--------------------------------------------------------------------------\n    | Inventory Class\n    |--------------------------------------------------------------------------\n    /\n    / The class of inventory model that holds all inventories. The model\n    / must be or extend `IvanSotelo\\Inventory\\Inventory::class`\n    / for the inventory package to work properly.\n    /\n    */\n    'inventory_model' =\u003e IvanSotelo\\Inventory\\Inventory::class,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Default field attribute\n    |--------------------------------------------------------------------------\n    /\n    / The name of the column which holds the key for the relationship with the model related to the inventory.\n    / You can change this value if you have set a different name in the migration for the inventories\n    / table. You might decide to go with the SKU field instead of the ID field.\n    /\n    */\n    'model_primary_field_attribute' =\u003e 'inventoriable_id',\n\n    /*\n    |--------------------------------------------------------------------------\n    | Allow no user\n    |--------------------------------------------------------------------------\n    |\n    | Allows inventory changes to occur without a user responsible.\n    |\n    */\n\n    'allow_no_user' =\u003e false,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Allow Duplicate Movements\n    |--------------------------------------------------------------------------\n    |\n    | Allows inventory stock movements to have the same before and after quantity.\n    |\n    */\n\n    'allow_duplicate_movements' =\u003e true,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Rollback Cost\n    |--------------------------------------------------------------------------\n    |\n    | For example, if the movement's cost that is being rolled\n    | back is 500, the rolled back movement will be -500.\n    |\n    */\n\n    'rollback_cost' =\u003e true,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Skus Enabled\n    |--------------------------------------------------------------------------\n    |\n    | Enables SKUs to be automatically generated on item creation.\n    |\n    */\n\n    'skus_enabled' =\u003e true,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Sku Prefix Length\n    |--------------------------------------------------------------------------\n    |\n    | The sku prefix length, not including the code for example:\n    |\n    | An item with a category named 'Sauce', the sku prefix generated will be: SAU\n    |\n    */\n\n    'sku_prefix_length' =\u003e 3,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Sku Code Length\n    |--------------------------------------------------------------------------\n    |\n    | The sku code length, not including prefix for example:\n    |\n    | An item with an ID of 1 (one) the sku code will be: 000001\n    |\n    */\n\n    'sku_code_length' =\u003e 6,\n\n    /*\n     * The sku separator for use in separating the prefix from the code.\n     *\n     * For example, if a hyphen (-) is inserted in the string below, a possible\n     * SKU might be 'DRI-00001'\n     *\n     * @var string\n     */\n\n    /*\n    |--------------------------------------------------------------------------\n    | Sku Separator\n    |--------------------------------------------------------------------------\n    |\n    | The sku separator for use in separating the prefix from the code.\n    |\n    | For example, if a hyphen (-) is inserted in the string\n    | below, a possible SKU might be 'DRI-00001'\n    |\n    */\n\n    'sku_separator' =\u003e '',\n\n];\n```\n\n## Usage\n\nAdd the HasInventory to the Model, the trait will enable inventory tracking.\n\n```php\n...\nuse IvanSotelo\\Inventory\\HasInventory;\n\nclass Product extends Model\n{\n    use HasInventory;\n\n    ...\n}\n```\n\n### Functions\n\n```php\n...\n$product = Product::first();\n\n$product-\u003eset(10); // $product-\u003ecurrentInventory()-\u003equantity; (Will result in 10)\n\n$product-\u003ecurrentInventory() //Return inventory instance\n\n$product-\u003eadd(5); // $product-\u003ecurrentInventory()-\u003equantity; (Will result in 15)\n\n$product-\u003etake(5); // $product-\u003ecurrentInventory()-\u003equantity; (Will result in 10)\n\n$product-\u003einInventory(); // Return true\n\n$product-\u003eclearInventory(); // $product-\u003ecurrentInventory(); (return null)\n\n$product-\u003enotInInventory(); // Return true\n\n--- Scopes ---\n\nProduct::InventoryIs(10)-\u003eget(); // Return all products with inventory of 10\n\nProduct::InventoryIs(10, '\u003e=')-\u003eget(); // Return all products with inventory of 10 or greater\n\nProduct::InventoryIs(10, '\u003c=')-\u003eget(); // Return all products with inventory of 10 or less\n\nProduct::InventoryIs(10, '\u003e=', [1,2,3])-\u003eget(); // Return all products with inventory of 10 or greater where product id is [1,2,3]\n\nProudct::InventoryIsNot(10)-\u003eget(); // Return all products where inventory is not 10\n\nProudct::InventoryIsNot(10, [1,2,3])-\u003eget(); // Return all products where inventory is not 10 where product id is 1,2,3\n```\n\n\n## Usage\n\nThe package fires these events:\n- `InventoryUpdate`: Inventory changes.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Ivan Sotelo](https://github.com/IvanSotelo)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivansotelo%2Flaravel-inventory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivansotelo%2Flaravel-inventory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivansotelo%2Flaravel-inventory/lists"}