82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace app\admin\model\user\invoice;
|
||
|
|
||
|
use think\Model;
|
||
|
|
||
|
|
||
|
class Header extends Model
|
||
|
{
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// 表名
|
||
|
protected $name = 'user_invoice_header';
|
||
|
|
||
|
// 自动写入时间戳字段
|
||
|
protected $autoWriteTimestamp = 'integer';
|
||
|
|
||
|
// 定义时间戳字段名
|
||
|
protected $createTime = 'createtime';
|
||
|
protected $updateTime = 'updatetime';
|
||
|
protected $deleteTime = false;
|
||
|
|
||
|
// 追加属性
|
||
|
protected $append = [
|
||
|
'head_type_text',
|
||
|
'invoice_type_text',
|
||
|
'is_default_text'
|
||
|
];
|
||
|
|
||
|
|
||
|
|
||
|
public function getHeadTypeList()
|
||
|
{
|
||
|
return ['personal' => __('Head_type personal'), 'corporate' => __('Head_type corporate')];
|
||
|
}
|
||
|
|
||
|
public function getInvoiceTypeList()
|
||
|
{
|
||
|
return ['ordinary' => __('Invoice_type ordinary'), 'special' => __('Invoice_type special')];
|
||
|
}
|
||
|
|
||
|
public function getIsDefaultList()
|
||
|
{
|
||
|
return ['0' => __('Is_default 0'), '1' => __('Is_default 1')];
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getHeadTypeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['head_type']) ? $data['head_type'] : '');
|
||
|
$list = $this->getHeadTypeList();
|
||
|
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] : '';
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getIsDefaultTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['is_default']) ? $data['is_default'] : '');
|
||
|
$list = $this->getIsDefaultList();
|
||
|
return isset($list[$value]) ? $list[$value] : '';
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
public function user()
|
||
|
{
|
||
|
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||
|
}
|
||
|
}
|