File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 11# Change Log
22
3+ ## New version
4+
5+ 1 . Adding ` Eloquent ` data source class to handle eloquent query
6+
37## Version 1.7.0
48
591 . Detect secure connection to return correct url for assets.
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace koolreport \laravel ;
4+
5+ use \koolreport \core \Utility ;
6+
7+ class Eloquent extends \koolreport \core \DataSource
8+ {
9+ protected $ builder ;
10+ /**
11+ * Insert eloquent buikder to the pipe.
12+ *
13+ * @param mixed $builder
14+ */
15+ public function query ($ builder )
16+ {
17+ $ this ->builder = $ builder ;
18+ return $ this ;
19+ }
20+
21+ /**
22+ * Start piping data
23+ *
24+ * @return null
25+ */
26+ public function start ()
27+ {
28+ $ metaData = null ;
29+ foreach ($ this ->builder ->cursor () as $ item )
30+ {
31+ if (!$ metaData )
32+ {
33+ $ metaData = array (
34+ "columns " =>array ()
35+ );
36+ foreach ($ item ->toArray () as $ k =>$ v )
37+ {
38+ $ metaData ["columns " ][$ k ] = array (
39+ "type " =>Utility::guessType ($ v )
40+ );
41+ }
42+ $ this ->sendMeta ($ metaData , $ this );
43+ $ this ->startInput (null );
44+ }
45+ $ this ->next ($ item ->toArray (), $ this );
46+ }
47+ $ this ->endInput (null );
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments