Laravel output:
Array
(
[0] = stdClass Object
(
[ID] = 5
)
[1] = stdClass Object
(
[ID] = 4
)
)
I suggest you simply do this within your method
public function MyAwesomeMethod($returnQueryAs = null)
{
$tablename = 'YourAwesomeTable';
if($returnQueryAs == 'array')
{
DB::connection()->setFetchMode(PDO::FETCH_ASSOC);
}
return DB::table($tablename)->get();
}
With this all you need is to pass the string 'array' as your argument and Voila! An Associative array is returned.