All Projects → appstract → Laravel Stock

appstract / Laravel Stock

Licence: mit
Keep stock for Eloquent models

Projects that are alternatives of or similar to Laravel Stock

Laravelinventry
Stock management application using Laravel 5.4
Stars: ✭ 60 (-73.8%)
Mutual labels:  stock, laravel
Laravel Crawler Detect
A Laravel wrapper for CrawlerDetect - the web crawler detection library
Stars: ✭ 227 (-0.87%)
Mutual labels:  laravel
Web Socket
Laravel library for asynchronously serving WebSockets.
Stars: ✭ 225 (-1.75%)
Mutual labels:  laravel
Wagonwheel
Offer an online version of your Laravel emails to users.
Stars: ✭ 224 (-2.18%)
Mutual labels:  laravel
Web
(DEPRECATED) An open source GUI to configure the machinery and to view events that were detected by the machinery.
Stars: ✭ 225 (-1.75%)
Mutual labels:  laravel
Laravel Craftsman
Laravel Craftsman CLI for easily crafting Laravel assets for any project (artisan make on steroids)
Stars: ✭ 227 (-0.87%)
Mutual labels:  laravel
Laravel Jwt
Dead simple, plug and play JWT API Authentication for Laravel (5.4+)
Stars: ✭ 225 (-1.75%)
Mutual labels:  laravel
Laravel Book
Up to date Epub, Mobi and PDF versions from the official Laravel Docs
Stars: ✭ 221 (-3.49%)
Mutual labels:  laravel
Fata
From Apprentice To Artisan. 在线阅读
Stars: ✭ 227 (-0.87%)
Mutual labels:  laravel
Laravel World
provide countries, states, and cities relations and database.
Stars: ✭ 222 (-3.06%)
Mutual labels:  laravel
Laravel Shareable Models
Create shareable links from your eloquent models.
Stars: ✭ 225 (-1.75%)
Mutual labels:  laravel
Bootstrap Form
Bootstrap 3 form builder for Laravel
Stars: ✭ 225 (-1.75%)
Mutual labels:  laravel
Laravel Tag Helper
Add powerful HTML tag helpers to your Laravel application
Stars: ✭ 227 (-0.87%)
Mutual labels:  laravel
Clamav Validator
Laravel virus validator based on ClamAV anti-virus scanner
Stars: ✭ 224 (-2.18%)
Mutual labels:  laravel
Laravel Database Mail Templates
Render Laravel mailables based on a mail template stored in the database
Stars: ✭ 226 (-1.31%)
Mutual labels:  laravel
Larastan
⚗️ Adds code analysis to Laravel improving developer productivity and code quality.
Stars: ✭ 3,554 (+1451.97%)
Mutual labels:  laravel
Wisteria
Beautiful document tool for your project.
Stars: ✭ 226 (-1.31%)
Mutual labels:  laravel
Laravel Views
Laravel package to create beautiful common views like data tables using the TALL stack.
Stars: ✭ 221 (-3.49%)
Mutual labels:  laravel
Learn Laravel
Laravel 学习资料和开源项目集
Stars: ✭ 229 (+0%)
Mutual labels:  laravel
Deeptrade keras
Stars: ✭ 228 (-0.44%)
Mutual labels:  stock

Laravel Stock

Latest Version on Packagist Total Downloads Software License Build Status

Keep stock for Eloquent models. This package will track stock mutations for your models. You can increase, decrease, clear and set stock. It's also possible to check if a model is in stock (on a certain date/time).

Installation

You can install the package via composer:

composer require appstract/laravel-stock

By running php artisan vendor:publish --provider="Appstract\Stock\StockServiceProvider" in your project all files for this package will be published. Run php artisan migrate to migrate the table. There will now be a stock_mutations table in your database.

Usage

Adding the HasStock trait will enable stock functionality on the Model.

use Appstract\Stock\HasStock;

class Book extends Model
{
    use HasStock;
}

Basic mutations

$book->increaseStock(10);
$book->decreaseStock(10);
$book->mutateStock(10);
$book->mutateStock(-10);

Clearing stock

It's also possible to clear the stock and directly setting a new value.

$book->clearStock();
$book->clearStock(10);

Setting stock

It is possible to set stock. This will create a new mutation with the difference between the old and new value.

$book->setStock(10);

Check if model is in stock

It's also possible to check if a product is in stock (with a minimal value).

$book->inStock();
$book->inStock(10);

Current stock

Get the current stock value (on a certain date).

$book->stock;
$book->stock(Carbon::now()->subDays(10));

Stock arguments

Add a description and/or reference model to de StockMutation.

$book->increaseStock(10, [
    'description' => 'This is a description',
    'reference' => $otherModel,
]);

Query Scopes

It is also possible to query based on stock.

Book::whereInStock()->get();
Book::whereOutOfStock()->get();

Testing

composer test

Contributing

Contributions are welcome, thanks to y'all :)

About Appstract

Appstract is a small team from The Netherlands. We create (open source) tools for Web Developers and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].