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.
45 lines
1.1 KiB
45 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Exports\ProductExport;
|
|
use App\Models\ProductExportLog;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
class ExportProductToExcel implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
private int $supplier_id;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(int $supplier_id)
|
|
{
|
|
$this->supplier_id = $supplier_id;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
$filePath = "supplier/export/{$this->supplier_id}/" . date('Y-m') . "/导出产品-" . date('Y-m-d_H-i-s') . '.xlsx';
|
|
Excel::store(new ProductExport($this->supplier_id), $filePath, 'public');
|
|
ProductExportLog::create([
|
|
'supplier_id' => $this->supplier_id,
|
|
'filename' => $filePath,
|
|
]);
|
|
}
|
|
}
|