海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
704 B

  1. <?php
  2. namespace App\AdminSupplier\Extensions;
  3. use App\Jobs\ExportProductToExcel;
  4. use Dcat\Admin\Grid\Exporters\AbstractExporter;
  5. /**
  6. * Excel导出功能
  7. */
  8. class ProductToExcelExporter extends AbstractExporter
  9. {
  10. public function export()
  11. {
  12. $export_type = request('_export_');
  13. if ($export_type == 'all') {
  14. $_export_ = 'all';
  15. } else if (str_starts_with($export_type, 'selected:')) {
  16. $_export_ = explode(',', substr($export_type, strlen('selected:')));
  17. $_export_ = array_filter($_export_, fn($v) => preg_match('/^\d+$/', $v));
  18. } else {
  19. return false;
  20. }
  21. ExportProductToExcel::dispatch(\Admin::user()->id, $_export_);
  22. return redirect(admin_url('product/export'))->send();
  23. }
  24. }