-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added get verified user by id in issue #18
- Loading branch information
1 parent
ef0ec77
commit 770527c
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\User; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\User; | ||
use App\Services\UserService; | ||
|
||
class UserController extends Controller | ||
{ | ||
public function getVerifiedUserById($userId) | ||
{ | ||
$verified_user = UserService::getVerifiedUser($userId); | ||
|
||
if (!$verified_user) { | ||
return response()->json([ | ||
'status' => false, | ||
'message' => 'User does not exist or is not a verified user' | ||
], 404); | ||
} | ||
|
||
return response()->json([ | ||
'status' => true, | ||
'user' => $verified_user | ||
], 200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
|
||
namespace App\Services; | ||
|
||
|
||
use App\Models\User; | ||
|
||
|
||
class UserService | ||
{ | ||
|
||
public static function getVerifiedUser($userId) | ||
{ | ||
$user = User::where('id', $userId)->where('isVerified', true)->first(); | ||
|
||
return $user; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters