You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.7 KiB
71 lines
1.7 KiB
1 year ago
|
<?php
|
||
|
|
||
|
namespace app\admin\model;
|
||
|
|
||
|
use think\Model;
|
||
|
|
||
|
|
||
|
class Goods extends Model
|
||
|
{
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// 表名
|
||
|
protected $name = 'goods';
|
||
|
|
||
|
// 自动写入时间戳字段
|
||
|
protected $autoWriteTimestamp = 'integer';
|
||
|
|
||
|
// 定义时间戳字段名
|
||
|
protected $createTime = 'createtime';
|
||
|
protected $updateTime = 'updatetime';
|
||
|
protected $deleteTime = false;
|
||
|
|
||
|
// 追加属性
|
||
|
protected $append = [
|
||
|
// 'on_time_text',
|
||
|
// 'off_time_text'
|
||
|
];
|
||
|
public function getStatusList()
|
||
|
{
|
||
|
return ['normal' => __('Normal'),'hidden'=>__('Hidden')];
|
||
|
}
|
||
|
public function user()
|
||
|
{
|
||
|
return $this->belongsTo('\app\admin\model\User', 'owner_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||
|
}
|
||
|
|
||
|
public function warehouse()
|
||
|
{
|
||
|
return $this->belongsTo('\app\admin\model\Warehouse', 'warehouse_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||
|
}
|
||
|
|
||
|
|
||
|
// public function getOnTimeTextAttr($value, $data)
|
||
|
// {
|
||
|
// $value = $value ? $value : (isset($data['on_time']) ? $data['on_time'] : '');
|
||
|
// return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||
|
// }
|
||
|
|
||
|
|
||
|
// public function getOffTimeTextAttr($value, $data)
|
||
|
// {
|
||
|
// $value = $value ? $value : (isset($data['off_time']) ? $data['off_time'] : '');
|
||
|
// return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||
|
// }
|
||
|
|
||
|
// protected function setOnTimeAttr($value)
|
||
|
// {
|
||
|
// return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||
|
// }
|
||
|
|
||
|
// protected function setOffTimeAttr($value)
|
||
|
// {
|
||
|
// return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||
|
// }
|
||
|
|
||
|
|
||
|
}
|