Add results page stub and fix some minor things
This commit is contained in:
parent
12a87f7611
commit
fd99a98438
|
@ -92,11 +92,11 @@ class PollController extends Controller
|
|||
|
||||
public function viewResults(Request $request, Poll $poll)
|
||||
{
|
||||
if($poll->results_visible) {
|
||||
$voted = $request->session()->pull('voted', false);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
return view('view_poll_results')
|
||||
->with('poll', $poll)
|
||||
->with('voted', $voted);
|
||||
}
|
||||
|
||||
private static function createPieChart(Poll $poll)
|
||||
|
@ -152,7 +152,6 @@ class PollController extends Controller
|
|||
$vote->poll_option_id = $option;
|
||||
$poll->votes()->save($vote);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
if($poll->duplicate_vote_checking == 'cookies') {
|
||||
|
@ -162,8 +161,7 @@ class PollController extends Controller
|
|||
$code->save();
|
||||
}
|
||||
|
||||
//return redirect('PollController@viewResults', ['poll' => $poll]);
|
||||
return view('view_poll')->with('poll', $poll)->with('new', false);
|
||||
return redirect()->action('PollController@viewResults', ['poll' => $poll])->with('voted', true);
|
||||
}
|
||||
|
||||
public function admin(Request $request, Poll $poll)
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace App;
|
|||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Poll extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
@ -58,6 +60,6 @@ class Poll extends Model
|
|||
|
||||
public function getResultsVisibleAttribute()
|
||||
{
|
||||
return !$this->hide_results_until_closed || ($this->closes_at != null && $this->closes_at->isPast());
|
||||
return !$this->hide_results_until_closed || ($this->closes_at != null && Carbon::parse($this->closes_at)->isPast());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ $type = $poll->allow_multiple_answers ? "checkbox" : "radio";
|
|||
<span>Voting URLs:</span>
|
||||
<textarea class="copyarea" readonly>{{$poll->voting_codes()->get()->map(function($c) use($poll) { return action('PollController@view', ['poll' => $poll, 'code' => $c]); })->implode("\n")}}</textarea>
|
||||
@else
|
||||
<span>Poll URL: <a href="{{ action('PollController@view', ['poll' => $poll]) }}"{{ action('PollController@view', ['poll' => $poll]) }}></a></span>
|
||||
<span>Poll URL: <a href="{{ action('PollController@view', ['poll' => $poll]) }}">{{ action('PollController@view', ['poll' => $poll]) }}</a></span>
|
||||
@endif
|
||||
</div>
|
||||
</section>
|
||||
|
@ -25,9 +25,9 @@ $type = $poll->allow_multiple_answers ? "checkbox" : "radio";
|
|||
<section @if($new) class="some-top-margin" @endif>
|
||||
@if ($hasVoted)
|
||||
@if (!$new || $poll->duplicate_vote_checking != 'codes')
|
||||
<span>You have already voted on this poll or need a code to vote.</span>
|
||||
|
||||
<br>
|
||||
<div class="primary-box">
|
||||
<span>You have already voted on this poll or need a code to vote.</span>
|
||||
</div>
|
||||
|
||||
@if ($poll->results_visible)
|
||||
<div class="some-top-margin">
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', "Results for '" . $poll->question . "'")
|
||||
|
||||
@section('content')
|
||||
@if ($voted)
|
||||
<section class="primary-box">
|
||||
<span>Your vote has been recorded!</span><br>
|
||||
</section>
|
||||
@endif
|
||||
|
||||
@if($poll->results_visible)
|
||||
<section class="grid grid--large @if($voted) some-top-margin @endif">
|
||||
<div>
|
||||
<div class="primary-box">
|
||||
<span>TODO: Put results here.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="primary-box">
|
||||
<span>TODO: Put a pie chart here.</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@else
|
||||
<section class="primary-box some-top-margin">
|
||||
<span>Results for this poll are hidden until the poll is closed.</span>
|
||||
</section>
|
||||
@endif
|
||||
@endsection
|
Loading…
Reference in New Issue