Laravel eloquent where makes array as object

Danabek Duisekov :

The structure is that:

$data = table->select->join->get();
if(...) {
    $data = $data->where();
}
return $data

So the first line returns array of objects. After that there is condition, if it's true, it makes this array like object, like:

{5: {...}, 6: {...}}

I need if = true, then I need response [{}, {}]

TsaiKoga :

You can use collection method values() to make it without keys:

if(...) {
    $data = $data->where()->values()->all();
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=15515&siteId=1