lundi 26 avril 2021

Issue with Laravel casting Int to string when fetching from server?

I have my web application running on server. I tested the code in local and it works fine. I'm getting id as int from local server but string in hosted server.

Using PHP 7.3

$data = DB::table('users')
->select('id')
->get();

$data = $data->pluck(id);

(Local) output => [1,2,3]

(Hosted) output => ["1","2","3"]

Can any one help to resolve this issue? I can do loop to type cast but there are 100's for function in my controller. It is not possible to type cast each query.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire