Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

variable was used before it was defined [closed]

As you can see I get the following error: 'User' was used before it was defined no-use-before-define on line 127:

Screenshot of error

However, I import it on line 2: Screenshot of import

I just use it as usual on line 127: Screenshot of me using my variable

What am I missing here?

like image 903
JordyvD Avatar asked Sep 02 '25 09:09

JordyvD


1 Answers

Rename your variable from User to user. I suspect that it is confused that you have both a variable and an object you are trying to create using the same name. You could alternatively change the namespace import to something other than User.

like image 150
Max Weinzierl Avatar answered Sep 04 '25 22:09

Max Weinzierl