PHP code example of mendela92 / laravel-stock

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

    

mendela92 / laravel-stock example snippets




use Mendela92\Stock\Notifications\LowStockLevelNotification;

return [

    /*
    |--------------------------------------------------------------------------
    | Default table name
    |--------------------------------------------------------------------------
    |
    | Table name to use to store mutations.
    |
    */

    'table' => 'stocks',

    /*
   |--------------------------------------------------------------------------
   | Default notification stock level
   |--------------------------------------------------------------------------
   |
   | Default stock alert configuration values
   |
   */
    'alert' => [

        'notification' => env("STOCK_NOTIFICATION", true),

        'at' => env("NOTIFICATION_STOCK_LEVEL", 10),

        'to' => ['[email protected]'],

        'model' => LowStockLevelNotification::class,
    ],
];



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

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

$book->setStock(10);

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

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

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

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