Skip to content

基础使用

展示字段

php
$show->field('id', 'ID');
$show->field('text', 'text');

自定义显示

php
$show->field("update_time", "更新时间")->as(function ($update_time){
            return $update_time.":".$this->user_id;
        });

显示单张图片

php
$show->field("thumb", "主图")->image();

显示多张图片

php
 //默认存储格式为‘逗号隔开的字符串’
$show->field("images", "轮播图")->images();
 //存储格式为json
$show->field("images", "轮播图")-type("json")->images();
 //存储格式为‘逗号隔开的字符串’
$show->field("images", "轮播图")-type("string")->images();

显示音频

php
$show->field("video", "视频")->video();

显示视频

php
$show->field("video", "视频")->video();

显示html内容(不被转义)

php
$show->field("content", "详情")->unescape();

显示表格

php
$show->field("goodsOption", "规格")->table(function ($goodsOption) {
            $goodsOption = json_decode($goodsOption, true);
            $header = ["规格ID",
                "规格名称",
                "有效期",
                "状态",
                "原价",
                "进货价",];
            $rows = [];
            foreach ($goodsOption as $item) {
                $rows[] = [
                    $item["goods_option_id"],
                    $item["option_title"],
                    $item["times"],
                    $item["status"] ? "上架中" : "下架",
                    $item["official_price"],
                    $item["plat_price"],

                ];
            }
            return [$header, $rows];
        });