How to get user details by id or email in Laravel?

2024-04-20 08:15:12 Atul Verma Laravel

Get user by email 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;

Get user by id in Laravel 5

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

This post is submitted by one of our members. You may submit a new post here.

Related Tricks