Пример #1
0
 public function propositions()
 {
     $user = Auth::user();
     $propositionFactory = new PropositionFactory();
     $propositionsCount = $propositionFactory->getPropositionsCountByUser($user->userId());
     $viewUser = ['fullName' => $user->firstName() . " " . $user->lastName(), 'firstName' => $user->firstName(), 'lastName' => $user->lastName(), 'contactEmail' => $user->contactEmail(), 'email' => $user->email(), 'avatar' => $user->avatar(), 'belongsToSchool' => $user->belongsToSchool(), 'schoolEmail' => $user->googleEmail(), 'role' => $user->role(), 'propositionsCount' => $propositionsCount];
     $propositionFactory = new PropositionFactory();
     $userPropositions = $propositionFactory->getPropositionsByUser($user->userId());
     $viewPropositions = array();
     foreach ($userPropositions as $proposition) {
         $viewPropositions[$proposition->propositionId()] = ['id' => $proposition->propositionId(), 'propositionSort' => $proposition->propositionSort(), 'propositionLong' => $proposition->propositionLong(), 'propositionCreationDate' => Carbon::createFromTimestamp(strtotime($proposition->date_created()))->diffForHumans(), 'userHasVoted' => $propositionFactory->getUserVoteStatus($proposition->propositionId(), $user->userId()), 'upvotes' => $propositionFactory->getUpvotes($proposition->propositionId()), 'downvotes' => $propositionFactory->getDownvotes($proposition->propositionId()), 'commentsCount' => $propositionFactory->getCommentsCount($proposition->propositionId()), 'deadline' => $proposition->deadline(), 'statusId' => $proposition->status(), 'blockReason' => $proposition->blockReason(), 'ending_in' => Carbon::now()->diffInDays(Carbon::createFromTimestamp(strtotime($proposition->deadline())), false), 'marker' => $propositionFactory->getMarker($proposition->propositionId())];
     }
     return view('account_new.propositions', ['fullName' => $user->firstName() . " " . $user->lastName(), 'user' => $viewUser, 'propositions' => $viewPropositions]);
 }