且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Laravel中获取身份验证用户ID

更新时间:2023-12-03 22:01:22

您可以改用Auth::id().这从会话中获取.如果会话中不存在该查询,它将运行查询并从数据库中获取该查询.

You can use Auth::id() instead. This grabs it from the session. If one doesn't exist in the session, then it will run the query and grab it from the database.