123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\admin\model\shop;
- use think\Model;
- class OrderGoods extends Model
- {
- // 表名
- protected $name = 'shop_order_goods';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'salestate_text',
- 'commentstate_text'
- ];
- public function getSalestateList()
- {
- return ['0' => __('Salestate 0'), '1' => __('Salestate 1'), '2' => __('Salestate 2'), '3' => __('Salestate 3'), '4' => __('Salestate 4'), '5' => __('Salestate 5'), '6' => __('Salestate 6')];
- }
- public function getCommentstateList()
- {
- return ['0' => __('Commentstate 0'), '1' => __('Commentstate 1')];
- }
- public function getSalestateTextAttr($value, $data)
- {
- $value = $value ?: ($data['salestate'] ?? '');
- $list = $this->getSalestateList();
- return $list[$value] ?? '';
- }
- public function getCommentstateTextAttr($value, $data)
- {
- $value = $value ?: ($data['commentstate'] ?? '');
- $list = $this->getCommentstateList();
- return $list[$value] ?? '';
- }
- public function Order()
- {
- return $this->belongsTo('Order', 'order_sn', 'order_sn', [], 'LEFT');
- }
- }
|