@@ -12,7 +12,7 @@ class Eloquent extends \koolreport\core\DataSource
1212 * @param mixed $builder
1313 */
1414 protected $ builder ;
15- protected $ retrievingMethod ;
15+ protected $ retrievingMethod = null ;
1616
1717 public function query ($ builder , $ retrievingMethod = null )
1818 {
@@ -23,21 +23,21 @@ public function query($builder, $retrievingMethod = null)
2323
2424 public function sendMetaAndItem ($ metaData , $ item )
2525 {
26- if (!$ metaData )
26+ if (!$ metaData )
27+ {
28+ $ metaData = array (
29+ "columns " =>array ()
30+ );
31+ foreach ($ item ->toArray () as $ k =>$ v )
2732 {
28- $ metaData = array (
29- "columns " =>array ( )
33+ $ metaData[ " columns " ][ $ k ] = array (
34+ "type " =>Utility:: guessType ( $ v )
3035 );
31- foreach ($ item ->toArray () as $ k =>$ v )
32- {
33- $ metaData ["columns " ][$ k ] = array (
34- "type " =>Utility::guessType ($ v )
35- );
36- }
37- $ this ->sendMeta ($ metaData , $ this );
38- $ this ->startInput (null );
3936 }
40- $ this ->next ($ item ->toArray (), $ this );
37+ $ this ->sendMeta ($ metaData , $ this );
38+ $ this ->startInput (null );
39+ }
40+ $ this ->next ($ item ->toArray (), $ this );
4141 }
4242
4343 /**
@@ -53,7 +53,7 @@ public function start()
5353 {
5454 $ this ->sendMetaAndItem ($ metaData , $ item );
5555 }
56- } else {
56+ } else if ( $ this -> retrievingMethod == ' cursor ' || $ this -> retrievingMethod == null ) {
5757 foreach ($ this ->builder ->cursor () as $ item )
5858 {
5959 $ this ->sendMetaAndItem ($ metaData , $ item );
0 commit comments