/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $proposals = $this->proposalRepository->getUnprocessedFinishedProposals();
     foreach ($proposals as $proposal) {
         $this->info($proposal->title);
         $votes = $this->proposalVoteRepository->getProposalVotes($proposal->id);
         $for = 0;
         $against = 0;
         $neutral = 0;
         $abstain = 0;
         $votesCast = 0;
         foreach ($votes as $vote) {
             if ($vote->abstain) {
                 $abstain++;
             } else {
                 if ($vote->vote == '+1') {
                     $for++;
                 } elseif ($vote->vote == '0') {
                     $neutral++;
                 } elseif ($vote->vote == '-1') {
                     $against++;
                 }
                 $votesCast++;
             }
         }
         $this->info("For: " . $for);
         $this->info("Neutral: " . $neutral);
         $this->info("Against: " . $against);
         $this->info("Abstain: " . $abstain);
         $result = $for - $against;
         $quorum = true;
         $this->proposalRepository->setResults($proposal->id, $result, $votesCast, $for, $against, $neutral, $abstain, $quorum);
     }
 }
 public function vote($proposalId)
 {
     //validation
     $this->proposalVoteValidator->validate(\Request::all());
     $proposal = $this->proposalRepository->getById($proposalId);
     if (!$proposal->isOpen()) {
         throw new \BB\Exceptions\ValidationException("The proposal isn't open for voting");
     }
     $this->proposalVoteRepository->castVote($proposalId, \Auth::user()->id, \Request::get('vote'));
     \Notification::success("Vote cast");
     return \Redirect::back();
 }