Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Converting a single retrieved sql value to string in laravel

I am new in laravel, I want to convert SQL result to string in laravel, below is what I did even though I dont get the result a desire, that is returning client_name as a string.

  $client_name = DB::table('utility_data')
         ->select('client_name')
         ->where('identity_number', '=', $identity_number)
         first();

    dd($client_name);

Above script select client name from the database, I want to convert that value to a string, any idea on how to achieve this? This is what I get as result,
I want to extract the value "Nosi Chefane":

{#303 ▼

+"client_name": "Nosi Chefane"
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you printing it from a controller, just use return $client_name and you should see the data as a JSON object

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading