34 lines
891 B
PHP
34 lines
891 B
PHP
<?php
|
|
|
|
namespace app\adminapi\logic\community;
|
|
|
|
use app\common\logic\BaseLogic;
|
|
use app\common\model\community\CommunityComment;
|
|
use app\common\model\community\CommunityPost;
|
|
|
|
class CommunityCommentLogic extends BaseLogic
|
|
{
|
|
public static function updateStatus(array $params): bool
|
|
{
|
|
try {
|
|
CommunityComment::update([
|
|
'id' => $params['id'],
|
|
'status' => $params['status'],
|
|
]);
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static function delete(array $params)
|
|
{
|
|
$comment = CommunityComment::findOrEmpty($params['id']);
|
|
if (!$comment->isEmpty()) {
|
|
CommunityPost::where('id', $comment->post_id)->dec('comment_count')->update();
|
|
$comment->delete();
|
|
}
|
|
}
|
|
}
|