Closed frzacode closed 3 years ago
Hi @frzacode what version are you using? 4.x does not have that method, 3.x does.
i think the newest one because i installed it via composer just now
if this method doesn't work with 4.x, what method should i use?
In the new version you should first create a result object and then you can use $result->getMimeType() to retrieve the type. The readme shows how you can generate a result object and call the method. Good luck ;)
why the examples on the readme don't work with the latest version? what's the point of having the examples then? Just google the error and check the amount of users that have the same problem. Something that should be simple is too complex for no reason.
Hi @x011 please let me know which example is incorrect and I will update it.
$qrCode = new QrCode($this->getImageData($image)); $decodedData = $qrCode->getText(); return $decodedData; when I use this code it gives me the error of Call to undefined method Endroid\QrCode\QrCode::getText() so how to fix this issue.
Hi @saranshquest the current version has no getText() method, see https://github.com/endroid/qr-code/blob/master/src/QrCode.php. You can check the readme for usage examples.
is it possible to scan the data from the qrcode and returns the all data which is present in the qrcode by the Endroid package in the laravel. public function scan(Request $request) { // Validate the uploaded file $request->validate([ 'qrCodeImage' => 'required|image', ]); // Get the uploaded file $qrCodeImage = $request->file('qrCodeImage'); $decodedData = $this->decodeQRCode($qrCodeImage); return response()->json(['data' => $decodedData]); } private function decodeQRCode($image) { $qrCode = new QrCode($this->getImageData($image)); $decodedData = $qrCode->getData(); return $decodedData; } private function getImageData($image) { $imagePath = $image->getRealPath(); $imageData = file_get_contents($imagePath);
return $imageData;
}
So please help me to get the data from the qrcode through the endroid package in the laravel.
@saranshquest This library is for creating QR codes, not for reading. You could try the khanamiryan/qrcode-detector-decoder
library for that purpose. Good luck!
i made function like this to try the qr code out: function coba_qrcode() { $qrCode = new \Endroid\QrCode\QrCode('Life is too short to be generating QR codes'); header('Content-Type: ' . $qrCode->getContentType()); echo $qrCode->writeString(); }
but the result is Type: Error Message: Call to undefined method Endroid\QrCode\QrCode::getContentType()