Aslero Asked:2020-09-10 17:09:02 +0800 CST2020-09-10 17:09:02 +0800 CST 2020-09-10 17:09:02 +0800 CST laravel 授权检查 772 为什么控制器中的这段代码不起作用?从数据库中检索第一条记录 $id = auth()->user()->id; $user = User::find($id)->first(); return view('profile.profile')->with(['profile' => $user]); laravel 2 个回答 Voted Best Answer Ruslan Mirzapulatov 2020-09-10T17:27:17+08:002020-09-10T17:27:17+08:00 您可以在视图中直接使用 Auth: {{ Auth::user()->name }} 如果您仍想传递给视图,则: return view('profile.profile', ['profile' => Auth::user()]); Hardc0re 2020-09-10T17:18:54+08:002020-09-10T17:18:54+08:00 return view('profile.profile')->with(['profile' => auth()->user()]);
您可以在视图中直接使用 Auth:
如果您仍想传递给视图,则: