Level 46
$user = DB::table('users')->where('name', 'John')->first()->pluck("phonenumber");
1 like
$user = DB::table('users')->where('name', 'John')->pluck("phonenumber"); when i use this type query it gives as array datatype even it is a single value how to get it as single value
if you use pluck as part of a query then you will get an array of results
using first will return the first of possibly many matches and the you can access the attributes directly without using pluck
$user = DB::table('users')->where('name', 'John')->first()->phonenumber;
Please or to participate in this conversation.