I've got a problem with all my queries with a varchar
ID returning an integer.
For example,a query which should return C-1451963448-MjL
returns instead 0.
My query:
$transaction = Transaction::with('user')->get();
return response()->json($transaction);
which returns:
[
{
"id": 0,
"user_id": 8,
"amount": "56164.00",
"created_at": "2016-01-05 10:10:48",
"user": {
"id": 8,
"facebook_id": null,
"first_name": "Alta",
"last_name": "Keebler",
}
},
]
the transaction id becoming 0. Last time I tried it succeeded, but now every ID with varchar
returns 0 instead of the real value.
I've tried to foreach
the get query, and yes the id is 0
.
I also tried to dd($transaction)
when i checked it, it return me with correct ID.
What should I do to make it work again?
Set $incrementing
to false on your model.
public $incrementing = false;
The casts system checks if this is set to true, if it is, it will try to cast the the key
field to an int.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With