I have one database table which contains multiple columns are there with different data types,one of the column is currency which is stored inside a database as an integer.
i have one API which is used for retrieving all the values from the database and displayed in UI,in my UI level they are accepting currency value as a string, is there any way to send the currency value as a string without changing the current structure of a database.,please give me some idea how to do this one..
>Solution :
There are multiple ways. one is to use attribute casting
class User extends Model
{
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'currency' => 'string',
];
}
Another radical solution would be to remove the module mysqlnd so everything is returned as string.