This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop/source/application/common/model/sharing/Comment.php

64 lines
1.3 KiB
PHP
Raw Normal View History

2020-04-25 22:20:29 +08:00
<?php
namespace app\common\model\sharing;
use app\common\model\BaseModel;
/**
* 拼团商品评价模型
* Class Comment
* @package app\common\model\sharing
*/
class Comment extends BaseModel
{
protected $name = 'sharing_comment';
/**
* 所属订单
* @return \think\model\relation\BelongsTo
*/
public function orderM()
{
return $this->belongsTo('Order');
}
/**
* 订单商品
* @return \think\model\relation\BelongsTo
*/
public function OrderGoods()
{
return $this->belongsTo('OrderGoods');
}
/**
* 关联用户表
* @return \think\model\relation\BelongsTo
*/
public function user()
{
$module = self::getCalledModule() ?: 'common';
return $this->belongsTo("app\\{$module}\\model\\User");
}
/**
* 关联评价图片表
* @return \think\model\relation\HasMany
*/
public function image()
{
return $this->hasMany('CommentImage', 'comment_id')->order(['id' => 'asc']);
}
/**
* 评价详情
* @param $comment_id
* @return Comment|null
* @throws \think\exception\DbException
*/
public static function detail($comment_id)
{
return self::get($comment_id, ['user', 'orderM', 'OrderGoods', 'image.file']);
}
}