public static function getAllRecords() { $sources = array(Contractor::where('status', '!=', 'deleted')->get(), Review::where('status', '!=', 'deleted')->get(), Service_request::all(), Lead::where('status', '!=', 'deleted')->get(), User::where('status', '!=', 'deleted')->get()); $sources_array = array(); $names_arr = array(); foreach ($sources as $source) { $source->last()->latest = 'Latest ' . get_class($source->last()); foreach ($source as $record) { All::formatRecord($record); } // $source->first()->classname = get_class($source->first()); array_push($sources_array, json_decode($source, TRUE)); array_push($names_arr, get_class($source->first())); } $big_arr = array_merge($sources_array[0], $sources_array[1], $sources_array[2], $sources_array[3], $sources_array[4]); // return $names_arr; return $big_arr; }