KTV/app/Jobs/ImportArtistJob.php
allen.yan c1125ae141 加入完成訊息
song 滙入大量歌曲會有問題 修正
加入 歌曲字數
加入 檔案完成後刪除功能
加入 暫存檔案刪除功能
20250507
2025-05-07 15:35:06 +08:00

45 lines
1.1 KiB
PHP

<?php
namespace App\Jobs;
use App\Imports\ArtistDataImport;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Storage;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Maatwebsite\Excel\Facades\Excel;
//use Illuminate\Foundation\Queue\Queueable;
class ImportArtistJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected string $filePath;
public $timeout = 3600;
/**
* Create a new job instance.
*/
public function __construct(string $filePath)
{
$this->filePath = $filePath;
}
/**
* Execute the job.
*/
public function handle(): void
{
ini_set('memory_limit', '-1'); // ✅ 增加記憶體限制
Excel::import(new ArtistDataImport, $this->filePath);
// 匯入完成後刪除檔案
if (Storage::exists($this->filePath)) {
Storage::delete($this->filePath);
}
}
}