Skip to content

Commit

Permalink
Correct resource response
Browse files Browse the repository at this point in the history
  • Loading branch information
Reza Esmaili committed Apr 3, 2022
1 parent fb29b06 commit 9d3838c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Http/Controllers/Api/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function vote_live($api_token)

return response()->json([
'data' => VoteEntryResource::collection($entries->load('competition'))
->toArrayRecursive(),
->toArrayRecursive(),
'status' => 200,
'message' => 'Livevotes loaded',
]);
Expand All @@ -233,6 +233,8 @@ public function vote_entries(Request $request, $api_token)
$visitor = Visitor::where('api_token', $api_token)
->first();

Session::put('visitor', $visitor->id);

if (is_null($visitor)) {
return response()->json([
'status' => 404,
Expand All @@ -257,12 +259,14 @@ public function vote_entries(Request $request, $api_token)
->pluck('id');

$entries = Entry::whereIn('id', $entryIds)
->orderBy('competition_id', 'ASC')
->orderBy('sort_position', 'ASC')
->get();

return response()->json([
'status' => 200,
'message' => 'Votes loaded',
'data' => EntryResource::collection($entries),
'data' => VoteEntryResource::collection($entries),
]);
}

Expand Down

0 comments on commit 9d3838c

Please sign in to comment.