Because get()
function of Query builder returns an array while I need A collection, is there a way to convert Laravel Query Builder to Eloquent Builder?
$query_builder = DB::table('table1');
// different than
$eloquent_builder = Table1Model::select()
Laravel ships with a
collect
helper to convert an array to a collection:There's a proposal on Github to have the next version of Laravel return collection instances from the query builder's
get
method.