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
28 lines
704 B
<?php
|
|
|
|
namespace App\AdminSupplier\Extensions;
|
|
use App\Jobs\ExportProductToExcel;
|
|
use Dcat\Admin\Grid\Exporters\AbstractExporter;
|
|
|
|
/**
|
|
* Excel导出功能
|
|
*/
|
|
class ProductToExcelExporter extends AbstractExporter
|
|
{
|
|
public function export()
|
|
{
|
|
$export_type = request('_export_');
|
|
|
|
if ($export_type == 'all') {
|
|
$_export_ = 'all';
|
|
} else if (str_starts_with($export_type, 'selected:')) {
|
|
$_export_ = explode(',', substr($export_type, strlen('selected:')));
|
|
$_export_ = array_filter($_export_, fn($v) => preg_match('/^\d+$/', $v));
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
ExportProductToExcel::dispatch(\Admin::user()->id, $_export_);
|
|
return redirect(admin_url('product/export'))->send();
|
|
}
|
|
}
|