123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\common\model\goods;
-
-
- use app\common\basics\Models;
- use app\common\model\order\OrderGoods;
-
- class GoodsComment extends Models
- {
-
-
- public function goods()
- {
- return $this->hasOne(Goods::class, 'id', 'goods_id')
- ->field('id,name,image');
- }
-
-
-
- public function goodsItem()
- {
- return $this->hasOne(GoodsItem::class, 'id', 'item_id')
- ->field('id,image,spec_value_str');
- }
-
-
-
- public function orderGoods()
- {
- return $this->hasOne(OrderGoods::class, 'id', 'order_goods_id')
- ->field('id,total_pay_price');
- }
-
-
-
- public function goodsCommentImage()
- {
- return $this->hasMany(GoodsCommentImage::class, 'goods_comment_id', 'id');
- }
-
- public function getStatusDescAttr($value)
- {
- return $value ? '显示' : '隐藏';
- }
-
- public function getGoodsCommentDescAttr($value)
- {
- $desc = [1=>'差评',2=>'差评',3=>'中评',4=>'好评',5=>'好评',];
- return $desc[$value];
- }
-
-
-
- function getCommentAttr($comment)
- {
- if (in_array(app('http')->getName(), [ 'admin', 'shop' ]) && request()->isAjax()) {
- $comment = htmlspecialchars($comment);
- }
-
- return $comment;
- }
- }
|