LiveRoomGoodsModel.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\admin\model;
  3. use app\admin\model\shopro\goods\Goods;
  4. use app\utils\CurlUtil;
  5. use think\Model;
  6. /**
  7. * 动态评论
  8. */
  9. class LiveRoomGoodsModel extends Model
  10. {
  11. // 表名
  12. protected $name = 'live_room_goods';
  13. // 开启自动写入时间戳字段
  14. protected $autoWriteTimestamp = false;
  15. // 定义时间戳字段名
  16. protected $createTime = false;
  17. protected $updateTime = false;
  18. protected $deleteTime = false;
  19. /**
  20. * 获取头像
  21. * @param string $value
  22. * @param array $data
  23. * @return string
  24. */
  25. public function getAvatarAttr($value, $data)
  26. {
  27. if (!$value) {
  28. //如果不需要启用首字母头像,请使用
  29. $value = CurlUtil::getHttp('/assets/img/avatar.png');
  30. // $value = letter_avatar($data['nickname']);
  31. }else{
  32. $value = cdnurl($value);
  33. }
  34. return $value;
  35. }
  36. public function room()
  37. {
  38. return $this->belongsTo(LiveRoom::class, 'room_id', 'id', [], 'LEFT')->setEagerlyType(0);
  39. }
  40. public function goods()
  41. {
  42. return $this->belongsTo(Goods::class, 'room_id', 'id', [], 'LEFT')->setEagerlyType(0);
  43. }
  44. }