I'm trying to sort a collection by the column name. I am logging the ajax result and when I sort by name I get:
Object: {0: Object, 1: Object, ...}
But when I sort by the other field (locationId) I get:
[Object, Object, ...]
Any idea what I'm doing wrong? I need the result in an array like when I sort by locationId.
public function getLocations()
{
return \Location::all(['locationId', 'name'])->sortBy('name');
}