如何在Laravel的刀片视图页面中允许$ user变量?

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?

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 }}

Within your Service Provider you can use

View::share('key', 'value')

You can consult the docs for a more indepth explanation.

Did you pass data in view file??

return view('support', ['user' => $user]);