Merhaba,
Şu şekilde bir excel okuması yapıyorum. Kodlar ve loga düşen hata konusunda yardımcı olabilir misiniz ?
Modelim :
class UrunExcel extends Model
{
protected $fillable = [
"StokNo",
"urunADI"
..... ];
}
Import Class'ım:
class UrunImport implements ToModel, WithBatchInserts, WithChunkReading,ShouldQueue
{
use Importable;
use Queueable, SerializesModels;
/**
* @param array $row
*
* @return UrunExcel | null
*/
public function model(array $row)
{
return new UrunExcel([
"StokNo" => $row[0],
"urunADI" => $row[1],
}
public function batchSize(): int
{
return 1000;
}
public function chunkSize(): int
{
return 1000;
}
}
İş katmanım:
public function EntegrasyonCalistir()
{
$excel_path = "urunler.xlsx";
(new UrunImport)->import(storage_path($excel_path), null, Excel::XLSX)
->allOnQueue('excel-imports')
->chain([
new UrunImportJob(new UrunExcel())
]);
// TODO: Implement EntegrasyonCalistir() method.
}
Job:
class UrunImportJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $urunExcel;
/**
* Create a new job instance.
* @param UrunExcel $urunExcel
* @return void
*/
public function __construct(UrunExcel $urunExcel)
{
$this->urunExcel = $urunExcel;
}
Job çalıştırdığımda
[2019-12-24 13:23:08][10] Processing: Maatwebsite\Excel\Jobs\QueueImport
[2019-12-24 13:23:08][10] Processed: Maatwebsite\Excel\Jobs\QueueImport
[2019-12-24 13:23:08][11] Processing: Maatwebsite\Excel\Jobs\ReadChunk
Aldığım hata log kayıtlarında şu şekilde:
local.ERROR: PDOStatement::execute(): MySQL server has gone away (SQL: insert into failed_jobs
Sebebini bilen biri var mı ? Veritabanına ekleyememesini anlayamadım.
Not: İş katmanındaki chunk fonksiyonunu doğru kullandığımdan emin değilim , sadece deniyorum