File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
classes/Controllers/Traits Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ trait Exportable
2121 */
2222 public function csv ()
2323 {
24- $ items = $ this ->makeIndexQuery ()-> exporting ()->get ();
24+ $ items = $ this ->makeCsvQuery ()->get ();
2525 if ($ items ->isEmpty ()) abort (404 );
2626 $ csv = $ this ->makeCsv ($ items );
2727 return response ($ csv ->getContent ())->withHeaders ([
@@ -33,6 +33,19 @@ public function csv()
3333 ]);
3434 }
3535
36+ /**
37+ * Make the CSV query, removing eager loading of images because that can
38+ * create a passing query that breaks some databases (like sql server)
39+ *
40+ * @return \Illuminate\Database\Eloquent\Builder
41+ */
42+ protected function makeCsvQuery ()
43+ {
44+ return $ this ->makeIndexQuery ()
45+ ->withoutGlobalScopes (['decoy.images ' ])
46+ ->exporting ();
47+ }
48+
3649 /**
3750 * Build the CSV object from a collection of models
3851 * https://csv.thephpleague.com/9.0/writer/
You can’t perform that action at this time.
0 commit comments