My question is similar with NodeJS get only value of MongoDB result.
But in this case, i'm using laravel.
This is my controller :
public function validation(Request $request)
{
$email= $request->input('email');
$password= $request->input('password');
if (DB::table('customer')
->where('email','=',$email)
->where('password','=',$password)
->exists())
{
$data=DB::table('customer')
->select('first_name')
->where('email','=',$email)
->project(['_id' => 0])
->get();
echo $data;
}
else
{
echo 'Wrong email or password';
}
}
And the output is :
[{"first_name":"John"}]
I want the result only
John
and removing field name, bracket, and the others.
What should i do ? And, is there any documentation for this ?