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)
|
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)
|
private static function createPieChart(Poll $poll)
|
||||||
|
@ -152,7 +152,6 @@ class PollController extends Controller
|
||||||
$vote->poll_option_id = $option;
|
$vote->poll_option_id = $option;
|
||||||
$poll->votes()->save($vote);
|
$poll->votes()->save($vote);
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
if($poll->duplicate_vote_checking == 'cookies') {
|
if($poll->duplicate_vote_checking == 'cookies') {
|
||||||
|
@ -162,8 +161,7 @@ class PollController extends Controller
|
||||||
$code->save();
|
$code->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
//return redirect('PollController@viewResults', ['poll' => $poll]);
|
return redirect()->action('PollController@viewResults', ['poll' => $poll])->with('voted', true);
|
||||||
return view('view_poll')->with('poll', $poll)->with('new', false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function admin(Request $request, Poll $poll)
|
public function admin(Request $request, Poll $poll)
|
||||||
|
|
|
@ -4,6 +4,8 @@ namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class Poll extends Model
|
class Poll extends Model
|
||||||
{
|
{
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
@ -58,6 +60,6 @@ class Poll extends Model
|
||||||
|
|
||||||
public function getResultsVisibleAttribute()
|
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>
|
<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>
|
<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
|
@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
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -25,9 +25,9 @@ $type = $poll->allow_multiple_answers ? "checkbox" : "radio";
|
||||||
<section @if($new) class="some-top-margin" @endif>
|
<section @if($new) class="some-top-margin" @endif>
|
||||||
@if ($hasVoted)
|
@if ($hasVoted)
|
||||||
@if (!$new || $poll->duplicate_vote_checking != 'codes')
|
@if (!$new || $poll->duplicate_vote_checking != 'codes')
|
||||||
<span>You have already voted on this poll or need a code to vote.</span>
|
<div class="primary-box">
|
||||||
|
<span>You have already voted on this poll or need a code to vote.</span>
|
||||||
<br>
|
</div>
|
||||||
|
|
||||||
@if ($poll->results_visible)
|
@if ($poll->results_visible)
|
||||||
<div class="some-top-margin">
|
<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