Skip to content

Commit

Permalink
Merge pull request #84 from workshopapps/BE-feat-getUsers
Browse files Browse the repository at this point in the history
feat: (BE) : get all users #18
  • Loading branch information
dasaint001 authored Nov 18, 2022
2 parents bff95d6 + 46da302 commit f085466
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 149 deletions.
24 changes: 23 additions & 1 deletion backend/app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@ public function __construct()
{
$this->middleware('auth:api');
}

public function allUsers(): JsonResponse
{
try{
$users = User::paginate(15);

if( !$user) {
return $this->errorResponse(
'No Record Found',
Response::HTTP_NOT_FOUND
);
}

return $this->successResponse(
true,
'All users',
$users,
Response::HTTP_OK
);
}catch (Exception $e) {
return $this->errorResponse('Records', $e->getMessage());
}
}

public function getUserById($user_id): JsonResponse
{
Expand Down Expand Up @@ -91,6 +114,5 @@ public function updateruserinfo(Request $request , $user_id): JsonResponse
}catch (Exception $e) {
return $this->errorResponse('User info not updated', $e->getMessage());
}

}
}
Loading

0 comments on commit f085466

Please sign in to comment.