Add votes to results page

This commit is contained in:
Les De Ridder 2018-10-18 01:16:03 +02:00
parent fd99a98438
commit 382ba5f87c
2 changed files with 23 additions and 3 deletions

View File

@ -14,6 +14,7 @@
.some-bottom-margin { margin-bottom: 0.5rem!important; }
.some-bottom-padding { padding-bottom: 3rem!important; }
.some-top-margin { margin-top: 2.0rem; }
.some-more-bottom-margin { margin-bottom: 2.0rem; }
.inline-block { display: inline-block; }
.primary-box {

View File

@ -10,10 +10,29 @@
@endif
@if($poll->results_visible)
<section class="grid grid--large @if($voted) some-top-margin @endif">
<div>
<section class="grid grid--large some-top-margin">
<div class="some-bottom-margin">
<div class="primary-box">
<span>TODO: Put results here.</span>
@php ($total = $poll->votes->count())
@foreach ($poll->options->sortByDesc(function($option) use($poll) { return $poll->votes->where('poll_option_id', $option->id)->count(); }) as $option)
@php ($votes = $poll->votes->where('poll_option_id', $option->id)->count())
<div class="some-more-bottom-margin">
<div>
<span>{{ $option->text }}</span>
<span style="float:right">{{ $votes }} votes</span>
</div>
<div>
<div style="background-color:#e83fb8;height:2rem;width:{{ $votes / $total * 100 }}%;">
</div>
</div>
</div>
@endforeach
<div class="some-top-margin">
<span>Total votes: {{ $total }}</span>
</div>
</div>
</div>
<div>