Qrcode class working only within route file

Asked

Viewed 29 times

1

Inside the route file the following code works normally:

QrCode::format('png')
      ->size(400)
      ->color(0,0,0,100)
      ->backgroundColor(255,255,255,0)
      ->margin(20)
      ->generate('google.com', public_path('images\qrcode7.png'));

But while trying to run inside the file RegisterController same command, error appears:

Class 'App\Http\Controllers\Auth\QrCode' not found

Any suggestions how to solve it? Inside the route file I didn’t import anything, and inside the controller also didn’t find any file that I import worked.

The library I’m using is the Simple Qrcode

1 answer

1


including

use SimpleSoftwareIO\QrCode\Generator;

and using it that way:

(new Generator)->format('png')->size(400)->color(0,0,0,100)->backgroundColor(255,255,255,0)->margin(20)->generate('google.com', public_path('images\qrcode7.png'));

It worked normally, I just didn’t understand why it works inside the route file that way

Browser other questions tagged

You are not signed in. Login or sign up in order to post.