diff --git a/src/Helpers/PollWriter.php b/src/Helpers/PollWriter.php
index 53886f1..5512205 100644
--- a/src/Helpers/PollWriter.php
+++ b/src/Helpers/PollWriter.php
@@ -35,7 +35,7 @@ public function draw($poll)
$voter = $poll->canGuestVote() ? new Guest(request()) : auth(config('larapoll_config.admin_guard'))->user();
- if (is_null($voter) || $voter->hasVoted($poll->id) || $poll->isLocked()) {
+ if (is_null($voter) || $voter->hasVoted($poll->id) || $poll->isLocked() || $poll->hasEnded()) {
if (!$poll->showResultsEnabled()) {
return 'Thanks for voting';
}
diff --git a/src/Http/Controllers/PollManagerController.php b/src/Http/Controllers/PollManagerController.php
index 8a5e60b..590f8a2 100644
--- a/src/Http/Controllers/PollManagerController.php
+++ b/src/Http/Controllers/PollManagerController.php
@@ -31,6 +31,7 @@ public function index()
$poll->isComingSoon = $poll->isComingSoon();
$poll->isLocked = $poll->isLocked();
$poll->isRunning = $poll->isRunning();
+ $poll->hasEnded = $poll->hasEnded();
$poll->edit_link = route('poll.edit', $poll->id);
$poll->delete_link = route('poll.remove', $poll->id);
$poll->lock_link = route('poll.lock', $poll->id);
@@ -124,6 +125,7 @@ public function lock(Poll $poll)
$poll->isComingSoon = $poll->isComingSoon();
$poll->isLocked = $poll->isLocked();
$poll->isRunning = $poll->isRunning();
+ $poll->hasEnded = $poll->hasEnded();
$poll->edit_link = route('poll.edit', $poll->id);
$poll->delete_link = route('poll.remove', $poll->id);
diff --git a/src/Http/Controllers/VoteManagerController.php b/src/Http/Controllers/VoteManagerController.php
index d708c60..4a52dd8 100644
--- a/src/Http/Controllers/VoteManagerController.php
+++ b/src/Http/Controllers/VoteManagerController.php
@@ -19,9 +19,7 @@ class VoteManagerController extends Controller
*/
public function vote(Poll $poll, Request $request)
{
-
try{
-
$vote = $this->resolveVoter($request, $poll)
->poll($poll)
->vote($request->get('options'));
diff --git a/src/Traits/PollAccessor.php b/src/Traits/PollAccessor.php
index 6b296d2..f4a12f9 100644
--- a/src/Traits/PollAccessor.php
+++ b/src/Traits/PollAccessor.php
@@ -1,7 +1,6 @@
isOpen() && $this->hasStarted();
+ return $this->isOpen() && $this->hasStarted() && !$this->hasEnded();
}
/**
@@ -104,4 +103,14 @@ public function isComingSoon()
{
return $this->isOpen() && now() < $this->starts_at;
}
+
+ /**
+ * If the poll has already ended
+ *
+ * @return bool
+ */
+ public function hasEnded()
+ {
+ return $this->ends_at < now();
+ }
}
diff --git a/src/Traits/Voter.php b/src/Traits/Voter.php
index 551568c..7dbbaac 100644
--- a/src/Traits/Voter.php
+++ b/src/Traits/Voter.php
@@ -46,7 +46,7 @@ public function vote($options)
if (is_null($this->poll))
throw new PollNotSelectedToVoteException();
- if ($this->poll->isLocked())
+ if ($this->poll->isLocked() || $this->poll->hasEnded())
throw new VoteInClosedPollException();
if ($this->hasVoted($this->poll->id))
diff --git a/src/views/dashboard/index.blade.php b/src/views/dashboard/index.blade.php
index 5da8f78..db0f93c 100644
--- a/src/views/dashboard/index.blade.php
+++ b/src/views/dashboard/index.blade.php
@@ -8,7 +8,6 @@
-