I\'m trying to convert a query to an array with the method toArray() but it doesn\'t work for the query builder. Any ideas for convert it?
toArray()
Example
And another solution
$objectData = DB::table('user') ->select('column1', 'column2') ->where('name', '=', 'Jhon') ->get(); $arrayData = array_map(function($item) { return (array)$item; }, $objectData->toArray());
It good in case when you need only several columns from entity.