Convert eloquent object to array collection

This is my select statement:

$users = User::where("username", "LIKE", "%" . $query . "%")
    ->select("username")
    ->get();

This currently outputs as:

[{"username":"Test"}]

I need it to output in one of the following formats:

{ 'data': ['result1', 'result2', ... ] }

OR

['result1', 'result2', ...]

How would I do this?


Solution 1:

Spoke too soon:

$users = User::where("username", "LIKE", "%" . $query . "%")
    ->lists("username");

return Response::json(array("data" => $users));

Solution 2:

$users = User::where("username", "LIKE", "%" . $query . "%")->select("username")->get()->toArray();