PHP code example of slowlyo / owl-sku

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

    

slowlyo / owl-sku example snippets


use Slowlyo\OwlSku\Sku;

// ...

// 使用组件
amis()->Form()->body([
    Sku::make()->form(),

    // 自定义 name 和 label
    Sku::make()->form('my_sku', 'My SKU'),

    // 自定义 sku 字段
    // 默认为 price 和 stock 两个字段
    Sku::make()->form('my_sku', 'My SKU', [
        amis()->TextControl('custom_1', '自定义字段1'),
        amis()->TextControl('custom_2', '自定义字段2'),
        amis()->TextControl('custom_3', '自定义字段3'),
        // ...
    ]),
])

use Slowlyo\OwlSku\Sku;

// 需要确保 sku 组件同级的数据域中有 id 字段, 值为 goods 表的 id (用于回显 sku 列表)

// sku 字段的数据需要作特殊处理

public function show () {
    return $this->response()->success([
        'id' => $goodsId,
        'sku' => Sku::make->echoData($goodsId)
    ]);
}