public function create(Request $request) {
$this->validate($request, [ \'email\' => \'required|email\', ]);
$user
Try with isEmpty()
, Like this :
public function create(Request $request) {
$validatedData = $request->validate([
'email' => 'required|email',
]);
$user = User::where('email', $request->email)->first();
if ($user->isEmpty()) {
return response()->json([
'message' => 'We can not find a user with that e-mail address.'
], 404);
} else {
return response()->json([
'message' => 'User is found'], 201 );
}
}