File tree Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Original file line number Diff line number Diff line change 3434 'disk ' => 'local ' ,
3535 ],
3636 ],
37-
38- 'sanitize ' => [
39- 'password ' ,
40- 'remember_token ' ,
41- ],
4237];
Original file line number Diff line number Diff line change @@ -15,15 +15,17 @@ public function build(): string
1515 $ csv .= implode (', ' , $ this ->columns )."\n" ;
1616
1717 // Add data rows
18- foreach ($ this ->data as $ row ) {
19- $ csvRow = [];
20- foreach ($ this ->columns as $ column ) {
21- $ value = $ row [$ column ] ?? '' ;
22- // Escape CSV values
23- $ csvRow [] = '" ' .str_replace ('" ' , '"" ' , $ value ).'" ' ;
18+ foreach ($ this ->columns as $ column ) {
19+ if (!array_key_exists ($ column , $ this ->data )) {
20+ $ csvRow [] = "'*****' " ;
21+ continue ;
2422 }
25- $ csv .= implode (', ' , $ csvRow )."\n" ;
23+
24+ $ value = $ this ->data [$ column ] ?? '' ;
25+ // Escape CSV values
26+ $ csvRow [] = '" ' .str_replace ('" ' , '"" ' , $ value ).'" ' ;
2627 }
28+ $ csv .= implode (', ' , $ csvRow )."\n" ;
2729
2830 return $ csv ;
2931 }
Original file line number Diff line number Diff line change 22
33namespace NaimSolong \DataExtractor \Builder ;
44
5+ use Illuminate \Database \DatabaseManager ;
56use InvalidArgumentException ;
67use RuntimeException ;
78
@@ -78,9 +79,16 @@ public function build(): string
7879 throw new RuntimeException ('Model not set. Use setModel() to set the model before building. ' );
7980 }
8081
82+ $ table = $ this ->model ->getTable ();
83+
84+ $ columns = app (DatabaseManager::class)
85+ ->connection ($ this ->model ->getConnectionName ())
86+ ->getSchemaBuilder ()
87+ ->getColumnListing ($ table );
88+
8189 $ this ->builder
82- ->setSchemaName ($ this -> model -> getTable () )
83- ->setColumns (array_keys ( $ this -> model -> getAttributes ()) )
90+ ->setSchemaName ($ table )
91+ ->setColumns ($ columns )
8492 ->setData ($ this ->model ->toArray ());
8593
8694 return $ this ->builder ->build ();
Original file line number Diff line number Diff line change @@ -11,7 +11,14 @@ public function build(): string
1111 {
1212 $ sql = '' ;
1313
14+ $ values = [];
15+
1416 foreach ($ this ->columns as $ column ) {
17+ if (!array_key_exists ($ column , $ this ->data )) {
18+ $ values [] = "'*****' " ;
19+ continue ;
20+ }
21+
1522 $ value = $ this ->data [$ column ];
1623
1724 if (is_array ($ value )) {
You can’t perform that action at this time.
0 commit comments