I don't see any particular problem here..
if you dd($fff) you only have 2 rows ? Then it comes from the data in the DB :/
Anyway you should use Eloquent model instead of DB class, more readable and easiest to use if you have relationship etc
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello everyone, This is my first post here, so I kindly ask you to be a liitle lenient to me.
I have set a Laravel API for a game I am building in Unity and evrything works fine, except for one thing. When I call the following function in my API I expect to get the details of some test users, but it seems I'm only getting the first two of the array I send. I guess ther is something wrong with my function.
$fff = \DB::table('users')->select('username','levels_unlocked', 'souvenirs','experience','country')
->whereIn('fbId', $request)
->orderBy('levels_unlocked', 'DESC')
->orderBy('souvenirs', 'DESC')
->orderBy('experience', 'DESC')
->get();
$friends = [
'message' => 'Successfully got the friends',
'Friend Details' => $fff,
];
return response()->json($friends, 200);
}
The POST data I am sending is this array:
{
"id": "109018004086476",
"picture": {
"data": {
"height": 50,
"is_silhouette": true,
"url": "https:\/\/scontent.fath3-3.fna.fbcdn.net\/v\/t31.0-1\/cp0\/c15.0.50.50a\/p50x50\/10733713_10150004552801937_4553731092814901385_o.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_ohc=drm1lEUx5A4AX-56ECf&_nc_ht=scontent.fath3-3.fna&oh=984d3a8b4ff8e940890df4f198962cef&oe=5EAAEFAC",
"width": 50
}
}
},
{
"id": "108789067444943",
"picture": {
"data": {
"height": 50,
"is_silhouette": true,
"url": "https:\/\/scontent.fath3-3.fna.fbcdn.net\/v\/t31.0-1\/cp0\/c15.0.50.50a\/p50x50\/10733713_10150004552801937_4553731092814901385_o.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_ohc=drm1lEUx5A4AX-56ECf&_nc_ht=scontent.fath3-3.fna&oh=984d3a8b4ff8e940890df4f198962cef&oe=5EAAEFAC",
"width": 50
}
}
},
{
"id": "106229827701237",
"picture": {
"data": {
"height": 50,
"is_silhouette": true,
"url": "https:\/\/scontent.fath3-3.fna.fbcdn.net\/v\/t31.0-1\/cp0\/c15.0.50.50a\/p50x50\/10733713_10150004552801937_4553731092814901385_o.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_ohc=drm1lEUx5A4AX-56ECf&_nc_ht=scontent.fath3-3.fna&oh=984d3a8b4ff8e940890df4f198962cef&oe=5EAAEFAC",
"width": 50
}
}
},
{
"id": "103444594649848",
"picture": {
"data": {
"height": 50,
"is_silhouette": true,
"url": "https:\/\/scontent.fath3-3.fna.fbcdn.net\/v\/t31.0-1\/cp0\/c15.0.50.50a\/p50x50\/10733713_10150004552801937_4553731092814901385_o.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_ohc=drm1lEUx5A4AX-56ECf&_nc_ht=scontent.fath3-3.fna&oh=984d3a8b4ff8e940890df4f198962cef&oe=5EAAEFAC",
"width": 50
}
}
},
{
"id": "101945741471074",
"picture": {
"data": {
"height": 50,
"is_silhouette": true,
"url": "https:\/\/scontent.fath3-3.fna.fbcdn.net\/v\/t31.0-1\/cp0\/c15.0.50.50a\/p50x50\/10733713_10150004552801937_4553731092814901385_o.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_ohc=drm1lEUx5A4AX-56ECf&_nc_ht=scontent.fath3-3.fna&oh=984d3a8b4ff8e940890df4f198962cef&oe=5EAAEFAC",
"width": 50
}
}
},
{
"id": "116821086632522",
"picture": {
"data": {
"height": 50,
"is_silhouette": true,
"url": "https:\/\/scontent.fath3-3.fna.fbcdn.net\/v\/t31.0-1\/cp0\/c15.0.50.50a\/p50x50\/10733713_10150004552801937_4553731092814901385_o.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_ohc=drm1lEUx5A4AX-56ECf&_nc_ht=scontent.fath3-3.fna&oh=984d3a8b4ff8e940890df4f198962cef&oe=5EAAEFAC",
"width": 50
}
}
},
{
"id": "115870070061766",
"picture": {
"data": {
"height": 50,
"is_silhouette": true,
"url": "https:\/\/scontent.fath3-3.fna.fbcdn.net\/v\/t31.0-1\/cp0\/c15.0.50.50a\/p50x50\/10733713_10150004552801937_4553731092814901385_o.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_ohc=drm1lEUx5A4AX-56ECf&_nc_ht=scontent.fath3-3.fna&oh=984d3a8b4ff8e940890df4f198962cef&oe=5EAAEFAC",
"width": 50
}
}
},
{
"id": "101866724812388",
"picture": {
"data": {
"height": 50,
"is_silhouette": true,
"url": "https:\/\/scontent.fath3-3.fna.fbcdn.net\/v\/t31.0-1\/cp0\/c15.0.50.50a\/p50x50\/10733713_10150004552801937_4553731092814901385_o.jpg?_nc_cat=1&_nc_sid=12b3be&_nc_ohc=drm1lEUx5A4AX-56ECf&_nc_ht=scontent.fath3-3.fna&oh=984d3a8b4ff8e940890df4f198962cef&oe=5EAAEFAC",
"width": 50
}
}
}
]
I have testing this in Insomnia moving the nodes around, and what I get is just the first and the second fff (Facebook Flarrot Friend)
Thanks for reading this and thanks in advance for any suggestions!
I don't see any particular problem here..
if you dd($fff) you only have 2 rows ? Then it comes from the data in the DB :/
Anyway you should use Eloquent model instead of DB class, more readable and easiest to use if you have relationship etc
Please or to participate in this conversation.