wesmiler 1 روز پیش
والد
کامیت
e047cfef4d
1فایلهای تغییر یافته به همراه20 افزوده شده و 0 حذف شده
  1. 20 0
      app/Models/GoodsCommentModel.php

+ 20 - 0
app/Models/GoodsCommentModel.php

@@ -22,6 +22,14 @@ class GoodsCommentModel extends BaseModel
     // 设置数据表
     protected $table = 'goods_comments';
 
+    protected $appends = ['time_text'];
+
+    // 时间
+    public function getTimeTextAttribute()
+    {
+        return $this->create_time? datetime($this->create_time,'Y-m-d H:i:s') : '';
+    }
+
     /**
      * 发布用户
      * @return \Illuminate\Database\Eloquent\Relations\HasOne
@@ -31,4 +39,16 @@ class GoodsCommentModel extends BaseModel
         return $this->hasOne(MemberModel::class, 'id', 'user_id')
             ->select(['id','openid', 'mobile', 'nickname','balance', 'realname', 'status']);
     }
+
+
+
+    /**
+     * 订单
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function order()
+    {
+        return $this->hasOne(OrderModel::class, 'id', 'order_id')
+            ->select(['id','order_no', 'user_id', 'total','status']);
+    }
 }