1
This commit is contained in:
@@ -32,7 +32,7 @@ class ArticleService extends BaseService
|
||||
return [
|
||||
'filters' => $params['filters'],
|
||||
'fields' => ['id', 'locale', 'title', 'subtitle', 'cover', 'content', 'user_id', 'is_top', 'sort', 'status', 'publish_time', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'relations' => [
|
||||
'creater' => ['id', 'nickname',],
|
||||
'comment' => ['id', 'article_id', 'content', 'avatar', 'name',],
|
||||
// 'translation' => ['model_id', 'name'],
|
||||
@@ -56,7 +56,7 @@ class ArticleService extends BaseService
|
||||
['field' => 'id', 'operator' => '=', 'value' => $params['id']]
|
||||
],
|
||||
'fields' => ['id', 'locale', 'title', 'subtitle', 'cover', 'content', 'user_id', 'is_top', 'sort', 'status', 'publish_time', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'relations' => [
|
||||
'comment' => ['id', 'article_id', 'content', 'avatar', 'name',],
|
||||
// 'translation' => ['model_id', 'name']
|
||||
],
|
||||
@@ -68,9 +68,9 @@ class ArticleService extends BaseService
|
||||
public function add(array $params)
|
||||
{
|
||||
$params['locale'] = locale();
|
||||
if(!empty($params['publish_time'])){
|
||||
if (!empty($params['publish_time'])) {
|
||||
$params['publish_time'] = strtotime($params['publish_time']);
|
||||
}else{
|
||||
} else {
|
||||
$params['publish_time'] = time();
|
||||
}
|
||||
$num = $params['num'] ?? 0;
|
||||
@@ -83,8 +83,8 @@ class ArticleService extends BaseService
|
||||
throw new BusinessException('提交失败');
|
||||
}
|
||||
|
||||
if($num > 0){
|
||||
CommentService::createComment($info->id,$params['content'],$num);
|
||||
if ($num > 0) {
|
||||
CommentService::createComment($info->id, $params['content'], $params['publish_time'], $num);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
@@ -109,8 +109,8 @@ class ArticleService extends BaseService
|
||||
throw new BusinessException('提交失败');
|
||||
}
|
||||
|
||||
if($num > 0){
|
||||
CommentService::createComment($id,$params['content'],$num);
|
||||
if ($num > 0) {
|
||||
CommentService::createComment($id, $params['content'], $params['publish_time'], $num);
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user