From b5d341716705b5a17002de53c4d21f821b8527dd Mon Sep 17 00:00:00 2001 From: Emmet Young Date: Thu, 29 Dec 2016 22:56:45 +1100 Subject: [PATCH] Allow listing a user by both ID and email. Useful for checking if a user exists by its email. --- app/Http/Controllers/API/UserController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/API/UserController.php b/app/Http/Controllers/API/UserController.php index 3b657bf02..0f645a7b7 100755 --- a/app/Http/Controllers/API/UserController.php +++ b/app/Http/Controllers/API/UserController.php @@ -75,7 +75,11 @@ class UserController extends BaseController */ public function view(Request $request, $id) { - $query = Models\User::where('id', $id); + if(is_numeric($id)) { + $query = Models\User::where('id', $id); + } else { + $query = Models\User::where('email', $id); + } if (! is_null($request->input('fields'))) { foreach (explode(',', $request->input('fields')) as $field) {