1616use Illuminate \Queue \SerializesModels ;
1717use Illuminate \Support \Arr ;
1818use Illuminate \Support \Facades \Auth ;
19+ use Illuminate \Support \Facades \File ;
1920use Illuminate \Support \Str ;
2021use PhpOffice \PhpSpreadsheet \Shared \Date ;
2122use Yajra \DataTables \Html \Column ;
@@ -53,6 +54,9 @@ public function __construct(array $dataTable, array $request, $user = null)
5354 * Execute the job.
5455 *
5556 * @return void
57+ * @throws \Box\Spout\Common\Exception\IOException
58+ * @throws \Box\Spout\Common\Exception\UnsupportedTypeException
59+ * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException
5660 */
5761 public function handle ()
5862 {
@@ -70,14 +74,20 @@ public function handle()
7074 $ dataTable = app ()->call ([$ oTable , 'dataTable ' ], compact ('query ' ));
7175 $ dataTable ->skipPaging ();
7276
77+ $ exportPath = storage_path ('app/exports ' );
78+
79+ if (! File::isDirectory ($ exportPath )) {
80+ File::makeDirectory ($ exportPath );
81+ }
82+
7383 $ type = Str::startsWith (request ('exportType ' ), Type::CSV ) ? Type::CSV : Type::XLSX ;
7484 $ writer = WriterEntityFactory::createWriter ($ type );
75- $ writer ->openToFile (storage_path ( ' app/exports/ ' . $ this ->batchId . '. ' . $ type) );
85+ $ writer ->openToFile ($ exportPath . ' / ' . $ this ->batchId . '. ' . $ type );
7686
7787 $ columns = $ oTable ->html ()->getColumns ()->filter ->exportable ;
7888 $ writer ->addRow (
7989 WriterEntityFactory::createRowFromArray (
80- $ columns ->map (fn ($ column ) => strip_tags ($ column ['title ' ]))->toArray ()
90+ $ columns ->map (fn ($ column ) => strip_tags ($ column ['title ' ]))->toArray ()
8191 )
8292 );
8393
@@ -123,7 +133,7 @@ public function handle()
123133 */
124134 protected function wantsDateFormat (Column $ column ): bool
125135 {
126- if (!isset ($ column ['exportFormat ' ])) {
136+ if (! isset ($ column ['exportFormat ' ])) {
127137 return false ;
128138 }
129139
0 commit comments