Php 导入excel文件时如何生成具有特殊id的二维码
这是我的进口代码Php 导入excel文件时如何生成具有特殊id的二维码,php,laravel,Php,Laravel,这是我的进口代码 class PesertaGuruImport implements ToCollection, WithChunkReading, ShouldQueue { public function __construct($id) { $this->id=$id; } /** * @param Collection $collection */ public function collection
class PesertaGuruImport implements ToCollection, WithChunkReading, ShouldQueue
{
public function __construct($id)
{
$this->id=$id;
}
/**
* @param Collection $collection
*/
public function collection(Collection $collection)
{
foreach ($collection as $key => $row) {
# code...
if ($key >= 1) {
$dt_peserta = [
'pelatihan_id' => $this->id,
'name' => $row[0],
'alamat' => $row[1],
'kota' => $row[2],
'telp' => $row[3],
'tmptlahir' => $row[4],
'tgllahir' => $row[5],
'fs' => $row[6],
'tj' => $row[7],
'gm' => $row[8],
'sl' => $row[9],
'mt' => $row[10],
'kriteria'=> $row[11],
'jilid' => $row[12],
'bersyahadah' => $row[13],
'lembaga'=> $row[14],
'munaqisy'=> $row[15],
'created_at' => new \DateTime,
];
\QrCode::size(500)
->format('png')
->generate('nurulfalah.org', public_path('images/'.$key.'qrcode.png'));
DB::table('pesertas')->insert($dt_peserta);
}
}
}
public function batchSize(): int
{
return 500;
}
public function chunkSize(): int
{
return 500;
}
}
我想用用户id生成二维码。
在这段代码中,我只得到索引的编号。用以下行替换生成的代码。实际生成()第一个参数是二维码的值,您总是传递“link”
\QrCode::size(500)
->format('png')
->generate($this->id, public_path('images/qrcode.png'));