Forked from sharifbdp/Add IF ELSE condition in Laravel Eloquent
Created
June 27, 2021 09:21
-
-
Save calvez/6f80a10d69fcb8fcbc17b4ceecce069e to your computer and use it in GitHub Desktop.
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
$type = $request->input('email_or_phone'); | |
$user = UserVerify::where('user_id', $request->input('user_id')) | |
->where(function($query) use ($type, $request) { | |
if ($type == 1) { | |
return $query->where('email', $request->input('email')); | |
} | |
if ($type == 2) { | |
return $query->where('mobile_no', $request->input('mobile_no')); | |
} | |
}) | |
->where('email_or_phone', $request->input('email_or_phone')) | |
->where('pin_code', $request->input('pin_code')) | |
->first(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment