fabpl/laravel-stock 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fabpl/laravel-stock

最新稳定版本:1.0

Composer 安装命令:

composer require fabpl/laravel-stock

包简介

Keep stock for Eloquent models.

README 文档

README

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

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

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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固