PHP code example of inquid / laravel-stock

1. Go to this page and download the library: Download inquid/laravel-stock 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/ */

    

inquid / laravel-stock example snippets




return [

    /*
    |--------------------------------------------------------------------------
    | Default table name
    |--------------------------------------------------------------------------
    |
    | Table name to use to store mutations.
    |
    */
    
    'table' => 'stock_mutations',
    
    'stock_mutation_model' => Inquid\Stock\StockMutation::class,
    
    //'special_date_class' => \MongoDB\BSON\UTCDateTime::class,
];

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

$book->increaseStock(10, ['warehouse' => $warehouse_first]);
$book->decreaseStock(10, ['warehouse' => $warehouse_first]);
$book->mutateStock(10, ['warehouse' => $warehouse_first]);
$book->mutateStock(-10, ['warehouse' => $warehouse_first]);

$book->clearStock();
$book->clearStock(10);
// With warehouse
$book->clearStock(10, ['warehouse' => $warehouse_first]);

$book->setStock(10);

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

$book->inStock(); // anywhere
$book->inStock(10);
$book->inStock(10, ['warehouse' => $warehouse_first]);

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

$book->stock(null, ['warehouse' =>$warehouse_first]);
$book->stock(Carbon::now()->subDays(10), ['warehouse' =>$warehouse_first]);

$book->moveBetweenStocks(5,$warehouse_first, $warehouse_second);

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

$book->setStock(10, ['warehouse' => $warehouse_first]);

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