스크린샷+2016-01-25+오후+8.37.13.png

blamed count와 voted count를 이용해서 상대적인 퍼센트를 구한 뒤, bootstrap의 progress bar에 style 속성으로 대입해서 구현했습니다. 색이 좀 맘에 걸리긴 하는데 디자인은 꽤 맘에 들게 뽑혔네요 ㅋ

 

게시판 스킨의 코멘트에

{@ $voted_comment = $comment->get('voted_count') + abs($comment->get('blamed_count')) }

{@ $positive_voted_comment = ($comment->get('voted_count') / $voted_comment)*100}
{@ $negative_voted_comment = ($comment->get('blamed_count') / $voted_comment)*100}

를 변수로 세팅하시믄 되고,

좀 더 깔끔하게 구현하고 싶으시면

{@ $positive_voted_comment = intval(($comment->get('voted_count') / $voted_comment)*100)}
{@ $negative_voted_comment = (100 - $positive_voted_comment)}

요렇게 세팅하믄 될 것 같구용.

 

style="width:{$negative_voted_comment};"

하시믄 되겠죵?

 

그런데, 0으로 나누면 안되니 $voted_comment가 0일때는 분기해줘야 합니다. 요렇게...

<!--@if($voted_comment == 0)-->
...
<!--@else-->
...
<!--@end-->