GoodsCommentModel.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Models;
  12. /**
  13. * 商品评论-模型
  14. * @author laravel开发员
  15. * @since 2020/11/11
  16. * @package App\Models
  17. */
  18. class GoodsCommentModel extends BaseModel
  19. {
  20. // 设置数据表
  21. protected $table = 'goods_comments';
  22. protected $appends = ['time_text'];
  23. // 时间
  24. public function getTimeTextAttribute()
  25. {
  26. return $this->create_time? datetime($this->create_time,'Y-m-d H:i:s') : '';
  27. }
  28. /**
  29. * 发布用户
  30. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  31. */
  32. public function user()
  33. {
  34. return $this->hasOne(MemberModel::class, 'id', 'user_id')
  35. ->select(['id','openid', 'mobile', 'nickname','balance', 'realname', 'status']);
  36. }
  37. /**
  38. * 订单
  39. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  40. */
  41. public function order()
  42. {
  43. return $this->hasOne(OrderModel::class, 'id', 'order_id')
  44. ->select(['id','order_no', 'user_id', 'total','status']);
  45. }
  46. }