I have a query that returns a boolean field (by the way, I'm on an SQL Server) on my REST API developed with Laravel and a few days ago it was returning the value as true/false, but now it returns that boolean value as String: "1"/"0".
Any idea on what could it be?
I tried using casting on my Model like this:
protected $casts = [
'status' => 'boolean',
];
This is my query:
return DB::table('dbo.visits as V')
->leftJoin('dbo.reports AS R', 'R.id_visit', '=', 'V.id')
->select('R.id','R.status'); // status is the boolean
Thanks in advance.
bit
?boolean
data type, so you can't have a query that returns one. If you want to store the valuesTRUE
/FALSE
you would have to use avarchar(5)
and the values'true'
and'false'
. Most people, however, use abit
, which allows the values0
and1
(andNULL
), however, it does not act like a boolean.