How to convert null values to empty string in Laravel 5.6 json response? - development

How to convert null values to empty string in Laravel 5.6 json response?

I have this response from my Laravel 5.6:

{
    "id": 1,
    "name": "Test",
    "email": "anything@example.com",
    "descr": null
}

It comes from this Laravel PHP code:

public function show($id) {
    return Client::find($id);
}

Is there any built-in function in Laravel 5.6 to change the null value to empty sting? I want to get back this json object:

{
    "id": 1,
    "name": "Test",
    "email": "anything@example.com",
    "descr": ""
}

Any idea?



from Laravel Questions and Answers https://laravelquestions.com/php/how-to-convert-null-values-to-empty-string-in-laravel-5-6-json-response/
via Lzo Media

Comments

Popular posts from this blog

ng-show doesn’t work correct with value boolean

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development

ng-include of inline SVG does not display gradient except in Chrome