Production.php 929 字节
<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Production extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'production';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';


    // 追加属性
    protected $append = [
        'one_image'
    ];


    public function getOneImageAttr($value,$data)
    {
        $arr = explode(',',$data['images']);
        foreach ($arr as $key => $val){
            $arr[$key] = cdnurl($val);
        }
        if (empty($arr)){
            return  '';
        }
        return $arr[0];
    }



    /**
     * 关联用户表
     */
    public function User(){
        return $this->belongsTo('user','user_id','id');
    }



}