审查视图

application/admin/model/OrderInvoice.php 1.9 KB
2  
杨育虎 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?php

namespace app\admin\model;

use think\Model;


class OrderInvoice extends Model
{

    

    

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

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

    // 追加属性
    protected $append = [
        'invoice_status_text',
2  
杨育虎 authored
29 30
        'invoice_type_text',
        'invoice_head_text'
2  
杨育虎 authored
31 32 33 34 35 36 37 38 39 40 41 42 43 44
    ];
    

    
    public function getInvoiceStatusList()
    {
        return ['1' => __('Invoice_status 1'), '2' => __('Invoice_status 2'), '3' => __('Invoice_status 3'), '4' => __('Invoice_status 4')];
    }

    public function getInvoiceTypeList()
    {
        return ['1' => __('Invoice_type 1'), '2' => __('Invoice_type 2')];
    }
2  
杨育虎 authored
45 46 47 48 49
    public function getInvoiceHeadList()
    {
        return ['1' => __('Invoice_head 1'), '2' => __('Invoice_head 2')];
    }
2  
杨育虎 authored
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

    public function getInvoiceStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['invoice_status']) ? $data['invoice_status'] : '');
        $list = $this->getInvoiceStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getInvoiceTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['invoice_type']) ? $data['invoice_type'] : '');
        $list = $this->getInvoiceTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

2  
杨育虎 authored
67 68 69 70 71 72 73 74
    public function getInvoiceHeadTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['invoice_head']) ? $data['invoice_head'] : '');
        $list = $this->getInvoiceHeadList();
        return isset($list[$value]) ? $list[$value] : '';
    }

2  
杨育虎 authored
75 76 77 78 79 80 81


    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}