#Undefined variable $users

35 messages · Page 1 of 1 (latest)

lucid orchid
#

Where are you returning the welcome view from? What controller/route?

#

Where ever you are returning it, you’re not passing a $users variable to the view.

#

By… passing it?

#

The view doesn’t know what the value of $users should be unless you actually tell it.

#

Well I asked you how you were returning the view, you didn’t answer.
I’ve also told you the solution (you need to actually pass the variable to the view).

lucid orchid
#

Mate. I can’t see your screen. I have no idea what code you have.

#

Please familiarise yourself with the #rules, particularly 1️⃣

#

1️⃣ Help us help you - Search the documentation before posting your issue and explain what you're doing and include any error messages you have received.

#

#

You haven’t shown a single line of code.

#

For the controller or route that’s actually returning the welcome view.

#

You have two routes that both return the welcome view. So which URL are you hitting?

#

Cool. That’s not what I asked though.

#

Which URL are you hitting, that gives you the error?

red epoch
#

I think he is following the link that serve is giving him so we can say localhost/ and not localhost/users?!

lucid orchid
red epoch
#

@delicate torrent did you try to add /users to the url?

#

Are you trying to access localhost/ or localhost/users?

lucid orchid
#

Mate. What address is in your browser’s address bar when you get the error?

#

Well, yes. You don’t seem to understand what a URL is.

#

It was a pretty simple question I was asking.

#

You get an error. What address is in your browser’s address bar when you get that error?

#

Once we know what URL you’re trying to access, we know what route is being accessed. And can continue diagnosing the issue.

#

This has nothing to do with being “new” to Laravel.

#

The address. What address are you hitting when you get an error?

red epoch
#

He is asking about your webbrowser url. Like in Chrome https://google.com

lucid orchid
#

Cool. Thanks for wasting both of our time then.

#

I’m sure you’ll get far with an attitude like that.

red epoch
#

Yeah php artisan serve is starting the webserver and gives you the url of the website inside the terminal/console but then you have opened you browser to access it like chrome, firefox, safari and there you got something like 127.0.0.1:8000/SOMETHING that SOMETHING part is the important one. If you only got ...8000/ there you welcome view is not getting anything because the first route got used.
So if you try to access http://127.0.0.1:8000/users it should work there? Try this links pls

lucid orchid
#

Right. So if you are hitting just http://localhost:8000, then it’s matching this route:

Route::get('/', function () {
    return view('welcome');
    
});

Which isn’t a controller, and isn’t passing a $users variable to the view, hence the “variable is undefined” error.

lucid orchid
#

@delicate torrent Good talk 🙄

#

Well I’m trying to help you, and instead you’ve decided to throw a temper tantrum and also go and delete all of your past messages.

#

How is asking for code, or asking what URL you’re on, “for professionals only”?

#

If you’re going to act like a frigging baby then yeah, you’re not going to get any help from here. Go somewhere else. Absolute child.

#

Blocked.