PHPackages                             shanjing/dcat-easy-sku - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. shanjing/dcat-easy-sku

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shanjing/dcat-easy-sku
======================

基于Dcat Admin的Sku插件

1.3(1y ago)0187MITJavaScriptPHP &gt;=7.1.0

Since Dec 7Pushed 1y agoCompare

[ Source](https://github.com/shanjing-inc/dcat-easy-sku)[ Packagist](https://packagist.org/packages/shanjing/dcat-easy-sku)[ Docs](https://github.com/lty5240/dcat-easy-sku)[ RSS](/packages/shanjing-dcat-easy-sku/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Dcat Easy Sku
=============

[](#dcat-easy-sku)

> 首先感谢前人的肩膀

该插件是 [Dcat Admin](https://learnku.com/docs/dcat-admin/) 的插件，安装方式遵循Dcat Admin官方文档

默认规格带有 图片，库存，价格 三个属性， 可自行添加属性，自行处理

安装
--

[](#安装)

#### composer安装

[](#composer安装)

```
composer require lty5240/dcat-easy-sku
```

#### 应用商店安装

[](#应用商店安装)

```
等待Dcat Admin 上商店

```

#### 本地安装

[](#本地安装)

```
下载本项目的zip包，并在Dcat Admin后台插件管理安装

// 不推荐，因为我没试过，也不方便

```

使用
--

[](#使用)

#### Controller

[](#controller)

```
Form::make($builder, function(Form $form){
    $sku_params = [
        [
            'name'    => '拓展列第一列', // table 第一行 title
            'field'   => 'column1', // input 的 field_name 名称
            'default' => '5', // 默认值
        ],
        [
            'name'    => '拓展列第二列',
            'field'   => 'column2',
            'default' => '',
        ],
    ];

    $form->sku('sku', json_encode($sku_params))->display(true)->customFormat(function ($value) use ($form){
        if($value === null){
            // 这里是给sku喂数据， 数据格式为
            $data = new stdClass();

            $data->attrs = [
                '颜色' => [
                    '红色',
                    '蓝色',
                ],
                '大小' => [
                    '20',
                ],
            ];
            $data->sku = [
                [
                    "颜色" => "红色",
                    "大小" => '20',
                    "pic" => '图片',
                    "stock" => '库存',
                    "price" => '价格',
                    ...
                    // 如果存在其他属性，则同样在这里塞进去
                ],
                ...
                // 根据attrs做笛卡尔积，会有两种情况， 红色20 蓝色20，所以这两中都应该有，自行编辑数据
            ];
            return json_encode($data);
        }
        return null;
    });
});
```

#### 排除sku(或者你自己改了名字)

[](#排除sku或者你自己改了名字)

##### 使用表单回调

[](#使用表单回调)

> 暂时无效好像

```
    $form->submitted(function (Form $form) {
        $this->sku = $form->input('sku');
        $form->deleteInput('sku');
    });
```

##### 直接简单粗暴排除

[](#直接简单粗暴排除)

在对应模型里

```
public function setSkuAttribute()
{
}
```

#### 保存数据

[](#保存数据)

```
// 可以用saved回调，等该模型保存完后，再进行处理
$form->saved(function (Form $form, int $result) {
    if ($result) {
        $sku = json_decode($form->input('sku'));
        $attrs = $sku->attrs;
        // 这边拿到sku的数据就自己处理吧
    }
}
```

#### 上传图片

[](#上传图片)

默认接口为 /api/skuImage, 可在js文件自行修改

```
    /**
     * 上传商品规格图片
     *
     * @param Request $request
     *
     * @return string[]
     */
    public function skuImage(Request $request)
    {
        if ($request->hasFile('file')) {
            $file = $request->file('file');
            $disk = Storage::disk('cosv5');
            $url = 'sku';
            $res = $disk->put($url, $file);
            // 返回格式
            return ['url' => config('app.cos.cdn') . $res];
        }
        return [];
    }
```

Licence
-------

[](#licence)

```
                                The MIT License (MIT)

                 Copyright (c) 2020-2021 Linty

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 70% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

522d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d2c0ca280c91473ed1158690018479964b201585454ec20afc3f6f45ef71831?d=identicon)[shanjing](/maintainers/shanjing)

---

Top Contributors

[![light-speak](https://avatars.githubusercontent.com/u/31815444?v=4)](https://github.com/light-speak "light-speak (7 commits)")[![PHPgoAllTheWay](https://avatars.githubusercontent.com/u/32635987?v=4)](https://github.com/PHPgoAllTheWay "PHPgoAllTheWay (2 commits)")[![hmilyfyj](https://avatars.githubusercontent.com/u/10796377?v=4)](https://github.com/hmilyfyj "hmilyfyj (1 commits)")

---

Tags

extensiondcat admin

### Embed Badge

![Health badge](/badges/shanjing-dcat-easy-sku/health.svg)

```
[![Health](https://phpackages.com/badges/shanjing-dcat-easy-sku/health.svg)](https://phpackages.com/packages/shanjing-dcat-easy-sku)
```

###  Alternatives

[sparkinzy/dcat-distpicker

省市区地址选择器，支持select2

272.7k1](/packages/sparkinzy-dcat-distpicker)[sparkinzy/dcat-marketplace

Dcat扩展市场

381.3k](/packages/sparkinzy-dcat-marketplace)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
