Skip to content

Commit ec1456e

Browse files
authored
fix(GAT-8119): update notifications (#1548)
1 parent d857f61 commit ec1456e

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

app/Http/Controllers/Api/V1/TeamNotificationController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ public function store(CreateTeamNotification $request, int $teamId)
180180

181181
// team has notifications
182182
$teamNotifications = TeamHasNotification::where('team_id', $teamId)->pluck('notification_id')->all();
183-
184183
if ($teamNotifications) {
185184
$this->deleteTeamNotifications($teamId, $teamNotifications);
186185
$this->createTeamNotifications($input, $teamId);

app/Http/Controllers/Api/V1/UserController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ public function show(GetUser $request, int $id): mixed
199199
{
200200
$input = $request->all();
201201
$jwtUser = array_key_exists('jwt_user', $input) ? $input['jwt_user'] : [];
202-
203202
try {
204203
$users = User::where([
205204
'id' => $id,
@@ -209,9 +208,10 @@ public function show(GetUser $request, int $id): mixed
209208
$userTeam = User::where('id', $id)->with(
210209
'roles',
211210
'roles.permissions',
212-
'teams',
213-
'notifications'
214-
)->get()->toArray();
211+
'teams.notifications',
212+
'notifications',
213+
'teamUsers.notifications'
214+
)->first();
215215

216216
Auditor::log([
217217
'user_id' => (int)$jwtUser['id'],
@@ -222,7 +222,7 @@ public function show(GetUser $request, int $id): mixed
222222

223223
return response()->json([
224224
'message' => 'success',
225-
'data' => $this->getUsers($userTeam),
225+
'data' => $userTeam,
226226
], 200);
227227
}
228228

app/Http/Traits/UserTransformation.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function getUsers(array $users): array
4545
'terms' => $user['terms'],
4646
'roles' => $user['roles'],
4747
'hubspot_id' => $user['hubspot_id'],
48+
'team_users' => $user['team_users'],
4849
];
4950

5051
$tmpTeam = [];
@@ -63,6 +64,7 @@ public function getUsers(array $users): array
6364
'application_form_updated_by' => $team['application_form_updated_by'],
6465
'application_form_updated_on' => $team['application_form_updated_on'],
6566
'is_question_bank' => $team['is_question_bank'],
67+
'notifications' => $team['notifications'],
6668
];
6769

6870
$teamHasUserId = (int)$team['pivot']['id'];
@@ -90,6 +92,7 @@ public function getUsers(array $users): array
9092
}
9193
$tmpUser['notifications'] = $tmpNotification;
9294

95+
9396
// Added in to stop a singular /users/:id call returning an array for
9497
// the users part of the payload
9598
if (count($users) === 1) {

0 commit comments

Comments
 (0)