OrderShow.php 3.5 KB
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
 * 管理端详情show trait层:渲染生成 Order 详情
+-----------------------------------------------------------------------------------------------------------------------
 *
 * PHP version 7
 *
 * @category  App\Admin\Shows
 * @package   App\Admin\Shows
 * @author    Richer <yangzi1028@163.com>
 * @date      2022年4月2日17:10:10
 * @copyright 2020-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
namespace App\Admin\Shows;

use App\Models\Order\Order;
use App\Models\User\Role;
use Illuminate\Support\Arr;

/**
 * Trait OrderShow.
 *
 * @category  App\Admin\Shows
 * @package   App\Admin\Shows
 * @author    Richer <yangzi1028@163.com>
 * @date      2022年4月2日17:10:10
 * @copyright 2020-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
trait OrderShow
{
    /**
     * 为详情show渲染字段
     *
     * @return void
     */
    protected function renderShowFields()
    {
        $this->showTextField('id');
        $this->showTextField('number', __('order_number'));
        $this->showTextField('type_show', __('type'));
        $this->show->divider();
//        $this->show->contents()->as(function ($content) {
//            return "<pre>{$content}</pre>";
//        });
        $this->showTextField('user.nickname', __('nickname'));
        $this->showSingleImageField('user.avatar', __('avatar'));
        $this->showTextField('user.mobile', __('mobile'));
        $this->showSingleSelectField('status', __('status'), Order::STATUS_OPTIONS, Order::STATUS_COLOR_OPTIONS);

        $this->show->divider();
        $this->show->express(__('express'), function ($express) {
            $express->express_company_show(__('express_company'));
            $express->express_no(__('express_no'));
            $express->express_info(__('express_info'))->unescape()->as(function ($express_info) {
                if (!$express_info) {
                    return '--';
                }

                $str ='<div class="track-list track-list-date"><ul>';
                foreach ($express_info as $key => $vo) {
                    if ($key === 0) {
                        $str .= '<li class="afterdate  node-to-change track-node-0008  first">';

                    } else {
                        $str .= '<li class="">';
                    }
                    $str .= '<i class="node-icon"><i class="dot"></i><i class="state-icon"></i></i><span class="date">'.$vo['datetime'].'</span>';
                    $str .= '<span class="txt">'.$vo['remark'].'</span>';
                    $str .= '</li>';
                }
                return $str;
            });
        });
//        $this->show->express(__('express'))->as(function ($express) {
//            if (!$express) {
//                return '--';
//            }
//
//
//            return "<pre>{$express}</pre>";
//        });

        $this->showDateField('created_at', __('ordered_at'));
        $this->showDateField('completed_at');
        $this->showDateField('cancelled_at');

//        $this->show->gifts(__('gift_records'), function ($gift) {

//            $gift->resource('/admin/comments');

//            $gift->id();
//            $gift->content()->limit(10);
//
//            $gift->filter(function ($filter) {
//                $filter->like('content');
//            });
//        });
    }
}