Reputation: 33
I have this page support.blade.php in views folder and I'm using Laravel.
I can't echo out $user->id
or $user[id]
in this page and I get undefined variable error. It's possible to echo it out in other pages, like in tickets.blade.php but in this specific page it's not working.
How can I fix this?
Upvotes: 3
Views: 1014
Reputation: 163898
You need to pass the data first from controller method:
return view('support', ['user' => $user]);
If you want to display ID of an authenticated user, you can do this from any part of the app without passing data from controller method:
{{ auth()->user()->id }}
Upvotes: 1
Reputation: 719
Did you pass data in view file??
return view('support', ['user' => $user]);
Upvotes: 0