I am working on a thread based messaging system.
I have a simple query to return all of the messages for a specific thread like that:
$t->messages->sortByDesc('updated_at')
While passing this to the return response()->json()
, if it has one message the return value is an array
. While if it has more than one messages the return value is an object
of objects like that {0 => {messageattribs}, 1 => {messageattribs}}
.
I would like to know why is this, and why it doesn't follow the array without the index keys patterns as in the first case.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire