/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     \App::setLocale(Auth::user()->language());
     $user = Auth::user();
     $viewUser = ['fullName' => $user->firstName() . " " . $user->lastName(), 'firstName' => $user->firstName(), 'lastName' => $user->lastName(), 'contactEmail' => $user->contactEmail(), 'email' => $user->email(), 'avatar' => $user->avatar(), 'belongsToSchool' => $user->belongsToSchool(), 'belongsToSchool' => $user->belongsToSchool(), 'schoolEmail' => $user->googleEmail(), 'role' => $user->role()];
     $propositionFactory = new PropositionFactory();
     $viewPropositions = array();
     $endingSoonPropositions = array();
     $votedPropositions = array();
     foreach ($propositionFactory->getAcceptedPropositionsExeptExpired() as $proposition) {
         $userHasVoted = $propositionFactory->getUserVoteStatus($proposition->propositionId(), $user->userId());
         $daysLeft = Carbon::now()->diffInDays(Carbon::createFromTimestamp(strtotime($proposition->deadline())), false);
         if ($daysLeft <= 5 and $daysLeft >= 0) {
             //Ending soon (5 days left)
             $endingSoonPropositions[$proposition->propositionId()] = ['id' => $proposition->propositionId(), 'propositionSort' => $proposition->propositionSort(), 'proposer' => $proposition->proposerId(), 'propositionCreationDate' => $proposition->date_created(), 'userHasVoted' => $userHasVoted, 'deadline' => $proposition->deadline(), 'statusId' => $proposition->status(), 'ending_in' => $daysLeft, 'upvotes' => $propositionFactory->getUpvotes($proposition->propositionId()), 'downvotes' => $propositionFactory->getDownvotes($proposition->propositionId()), 'comments' => $propositionFactory->getCommentsCount($proposition->propositionId()), 'marker' => $propositionFactory->getMarker($proposition->propositionId())];
         } elseif ($userHasVoted == true and $daysLeft > 0) {
             //Voted propositions
             $votedPropositions[$proposition->propositionId()] = ['id' => $proposition->propositionId(), 'propositionSort' => $proposition->propositionSort(), 'proposer' => $proposition->proposerId(), 'propositionCreationDate' => $proposition->date_created(), 'userHasVoted' => $userHasVoted, 'deadline' => $proposition->deadline(), 'statusId' => $proposition->status(), 'ending_in' => $daysLeft, 'upvotes' => $propositionFactory->getUpvotes($proposition->propositionId()), 'downvotes' => $propositionFactory->getDownvotes($proposition->propositionId()), 'comments' => $propositionFactory->getCommentsCount($proposition->propositionId()), 'marker' => $propositionFactory->getMarker($proposition->propositionId())];
         } else {
             $viewPropositions[$proposition->propositionId()] = ['id' => $proposition->propositionId(), 'propositionSort' => $proposition->propositionSort(), 'proposer' => $proposition->proposerId(), 'propositionCreationDate' => $proposition->date_created(), 'userHasVoted' => $userHasVoted, 'deadline' => $proposition->deadline(), 'statusId' => $proposition->status(), 'ending_in' => $daysLeft, 'upvotes' => $propositionFactory->getUpvotes($proposition->propositionId()), 'downvotes' => $propositionFactory->getDownvotes($proposition->propositionId()), 'comments' => $propositionFactory->getCommentsCount($proposition->propositionId()), 'marker' => $propositionFactory->getMarker($proposition->propositionId())];
         }
     }
     $modAlerts = array("approval" => $user->role() == User::ROLE_MODERATOR and $propositionFactory->getQueuedPropositionsExceptUsersCount($user->userId()) > 0, "flag" => $user->role() == User::ROLE_MODERATOR and $propositionFactory->getGlobalFlagCount($user->userId()) > 0);
     return view('propositions_new', ['fullName' => $user->firstName() . " " . $user->lastName(), 'user' => $viewUser, 'propositions' => $viewPropositions, 'endingSoonPropositions' => $endingSoonPropositions, 'votedPropositions' => $votedPropositions, 'modAlerts' => $modAlerts]);
 }