Laravel - Query Builder - Retrieving A Single Row Column From A Table

If you just need to retrieve a single row from a database table, you may use the DB facade's first method. This method will return a single stdClass object:

    
    $user = DB::table('users')->where('name', 'John')->first();
    
    return $user->email;
	

If you don't need an entire row, you may extract a single value from a record using the value method. This method will return the value of the column directly:

    
    $email = DB::table('users')->where('name', 'John')->value('email');
	

To retrieve a single row by its id column value, use the find method:

    
    $user = DB::table('users')->find(3);