Get user by id in laravel 5

Laravel function to get user details by email or id in Laravel

public function getUserByEmail(Request $request){
    $email =$request->input('email');
    $user = User::where('email',$email)->first();
    return $user;
}
of if id is known simply use

public function getUserById(Request $request){
	$id =$request->input('id');
    $user =  User::find($id);
    return $user;
}

Leave a Reply

Your email address will not be published. Required fields are marked *