Skip to content

Commit

Permalink
Merge pull request #231 from ledgerleapllc/development
Browse files Browse the repository at this point in the history
Sync development to staging
  • Loading branch information
ledgerleapllc authored Jan 2, 2023
2 parents c6b0e69 + 39368be commit f310e73
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions app/Http/Controllers/Api/V1/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1288,21 +1288,41 @@ public function getVotes(Request $request)
public function getVoteDetail($id)
{
$user = auth()->user()->load(['pagePermissions']);
if (Helper::isAccessBlocked($user, 'votes'))
return $this->errorResponse('Your access is blocked', Response::HTTP_BAD_REQUEST);

$ballot = Ballot::with(['vote', 'voteResults.user', 'files'])->where('id', $id)->first();
if (!$ballot)
return $this->errorResponse('Not found ballot', Response::HTTP_BAD_REQUEST);
if (Helper::isAccessBlocked($user, 'votes')) {
return $this->errorResponse(
'Your access is blocked',
Response::HTTP_BAD_REQUEST
);
}

$ballot = Ballot::with(['vote', 'voteResults.user', 'files'])
->where('id', $id)
->first();

if (!$ballot) {
return $this->errorResponse(
'Not found ballot',
Response::HTTP_BAD_REQUEST
);
}

foreach ($ballot->files as $file) {
$ballotFileView = BallotFileView::where('ballot_file_id', $file->id)->where('user_id', $user->id)->first();
$ballotFileView = BallotFileView::where(
'ballot_file_id',
$file->id
)->where('user_id', $user->id)->first();

$file->is_viewed = $ballotFileView ? 1 : 0;
}

foreach ($ballot->files as $file) {
$ballotFileView = BallotFileView::where('ballot_file_id', $file->id)
->where('user_id', $user->id)
->first();
$ballotFileView = BallotFileView::where(
'ballot_file_id',
$file->id
)
->where('user_id', $user->id)
->first();

$file->is_viewed = $ballotFileView ? 1 : 0;
}
Expand Down

0 comments on commit f310e73

Please sign in to comment.