1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\admin\model\bag;
- use think\Model;
- class Gift extends Model
- {
-
-
- // 表名
- protected $name = 'new_gift';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'gift_type_text'
- ];
-
-
- public function getGiftTypeList()
- {
- return ['1' => __('Gift_type 1'), '2' => __('Gift_type 2'), '3' => __('Gift_type 3'), '4' => __('Gift_type 4'), '5' => __('Gift_type 5')];
- }
- public function getGiftTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['gift_type']) ? $data['gift_type'] : '');
- $list = $this->getGiftTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function newbag()
- {
- return $this->belongsTo('app\admin\model\bag\Bag', 'bag_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|