public function index() { $perfil = RolUsuario::paginate(); $data = array(array('usuario_id', 'rol_id')); foreach ($perfil as $per) { $datos = array(); array_push($datos, $per->usuarios->rut, $per->roles->nombre); array_push($data, $datos); } Excel::create('Perfiles', function ($excel) use($data) { $excel->sheet('Sheetname', function ($sheet) use($data) { $sheet->fromArray($data); }); })->download('csv'); }