try laravel Appending Values To JSON
ref link https://laravel.com/docs/8.x/eloquent-serialization#appending-values-to-json
Modal
/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = ['qr_code'];
public function getQrCodeAttribute()
{
$binCode = $this->code ? $this->code : 123456;
return $this->attributes['qr_code'] = QrCode::size(200)->generate($binCode);
}
by this $AllBins
in this collection new key qr_code
will be added
so you can use pluck() to get all qr_code
$qrCodes = $AllBins->pluck('qr_code');
CLICK HERE to find out more related problems solutions.