承接 controlla_ccd/laravel-inventory 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

controlla_ccd/laravel-inventory

Composer 安装命令:

composer require controlla_ccd/laravel-inventory

包简介

Inventory Management for Laravel

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We 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. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require controlla/laravel-inventory

You can publish and run the migrations with:

php artisan vendor:publish --provider="Controlla\Inventory\InventoryServiceProvider" --tag="laravel-inventory-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="Controlla\Inventory\InventoryServiceProvider" --tag="laravel-inventory-config"

This is the contents of the published config file:

return [
    /*
    |--------------------------------------------------------------------------
    | Inventory Class
    |--------------------------------------------------------------------------
    /
    / The class of inventory model that holds all inventories. The model
    / must be or extend `Controlla\Inventory\Inventory::class`
    / for the inventory package to work properly.
    /
    */
    'inventory_model' => Controlla\Inventory\Inventory::class,

    /*
    |--------------------------------------------------------------------------
    | Default field attribute
    |--------------------------------------------------------------------------
    /
    / The name of the column which holds the key for the relationship with the model related to the inventory.
    / You can change this value if you have set a different name in the migration for the inventories
    / table. You might decide to go with the SKU field instead of the ID field.
    /
    */
    'model_primary_field_attribute' => 'inventoriable_id',

    /*
    |--------------------------------------------------------------------------
    | Allow no user
    |--------------------------------------------------------------------------
    |
    | Allows inventory changes to occur without a user responsible.
    |
    */

    'allow_no_user' => false,

    /*
    |--------------------------------------------------------------------------
    | Allow Duplicate Movements
    |--------------------------------------------------------------------------
    |
    | Allows inventory stock movements to have the same before and after quantity.
    |
    */

    'allow_duplicate_movements' => true,

    /*
    |--------------------------------------------------------------------------
    | Rollback Cost
    |--------------------------------------------------------------------------
    |
    | For example, if the movement's cost that is being rolled
    | back is 500, the rolled back movement will be -500.
    |
    */

    'rollback_cost' => true,

    /*
    |--------------------------------------------------------------------------
    | Skus Enabled
    |--------------------------------------------------------------------------
    |
    | Enables SKUs to be automatically generated on item creation.
    |
    */

    'skus_enabled' => true,

    /*
    |--------------------------------------------------------------------------
    | Sku Prefix Length
    |--------------------------------------------------------------------------
    |
    | The sku prefix length, not including the code for example:
    |
    | An item with a category named 'Sauce', the sku prefix generated will be: SAU
    |
    */

    'sku_prefix_length' => 3,

    /*
    |--------------------------------------------------------------------------
    | Sku Code Length
    |--------------------------------------------------------------------------
    |
    | The sku code length, not including prefix for example:
    |
    | An item with an ID of 1 (one) the sku code will be: 000001
    |
    */

    'sku_code_length' => 6,

    /*
     * The sku separator for use in separating the prefix from the code.
     *
     * For example, if a hyphen (-) is inserted in the string below, a possible
     * SKU might be 'DRI-00001'
     *
     * @var string
     */

    /*
    |--------------------------------------------------------------------------
    | Sku Separator
    |--------------------------------------------------------------------------
    |
    | The sku separator for use in separating the prefix from the code.
    |
    | For example, if a hyphen (-) is inserted in the string
    | below, a possible SKU might be 'DRI-00001'
    |
    */

    'sku_separator' => '',

];

Usage

Add the HasInventory to the Model, the trait will enable inventory tracking.

...
use Controlla\Inventory\HasInventory;

class Product extends Model
{
    use HasInventory;

    ...
}

Functions

...
$product = Product::first();

$product->set(10); // $product->currentInventory()->quantity; (Will result in 10)

$product->currentInventory() //Return inventory instance

$product->add(5); // $product->currentInventory()->quantity; (Will result in 15)

$product->take(5); // $product->currentInventory()->quantity; (Will result in 10)

$product->inInventory(); // Return true

$product->clearInventory(); // $product->currentInventory(); (return null)

$product->notInInventory(); // Return true

--- Scopes ---

Product::InventoryIs(10)->get(); // Return all products with inventory of 10

Product::InventoryIs(10, '>=')->get(); // Return all products with inventory of 10 or greater

Product::InventoryIs(10, '<=')->get(); // Return all products with inventory of 10 or less

Product::InventoryIs(10, '>=', [1,2,3])->get(); // Return all products with inventory of 10 or greater where product id is [1,2,3]

Proudct::InventoryIsNot(10)->get(); // Return all products where inventory is not 10

Proudct::InventoryIsNot(10, [1,2,3])->get(); // Return all products where inventory is not 10 where product id is 1,2,3

Usage

The package fires these events:

  • InventoryUpdate: Inventory changes.

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.

controlla_ccd/laravel-inventory 适用场景与选型建议

controlla_ccd/laravel-inventory 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 344 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel-inventory」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 controlla_ccd/laravel-inventory 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 controlla_ccd/laravel-inventory 我们能提供哪些服务?
定制开发 / 二次开发

基于 controlla_ccd/laravel-inventory 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-27