why
This commit is contained in:
parent
db22b830cf
commit
cb8d4a1501
1 changed files with 7 additions and 13 deletions
|
@ -143,20 +143,14 @@ class Comment
|
||||||
*/
|
*/
|
||||||
private function getVotes()
|
private function getVotes()
|
||||||
{
|
{
|
||||||
$votes = DB::table('comment_votes')
|
$this->upvotes = intval(DB::table('comment_votes')
|
||||||
->where('vote_comment', $this->id)
|
->where('vote_comment', $this->id)
|
||||||
->get();
|
->where('vote_state', 1)
|
||||||
|
->count());
|
||||||
$this->upvotes = 0;
|
$this->downvotes = intval(DB::table('comment_votes')
|
||||||
$this->downvotes = 0;
|
->where('vote_comment', $this->id)
|
||||||
|
->where('vote_state', 0)
|
||||||
foreach ($votes as $vote) {
|
->count());
|
||||||
if (intval($vote->vote_state) !== 0) {
|
|
||||||
$this->upvotes += 1;
|
|
||||||
} else {
|
|
||||||
$this->downvotes += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in a new issue