我已经看过这篇文章,但我似乎无法正确:
拉拉维尔表单模型绑定
我收到此错误:
https://gyazo.com/2ea7b7bb6a19d588829447ee1a92053e 我使用 laravel 5.2 为此。
一些截图:
https://gyazo.com/1b2c35e660dfe1aae69a02703733d083 https://gyazo.com/3d6f294473f6e54650a4a4403dc2777e https://gyazo.com/a59aebc7362f51f9ac27852ea032f962
扩展我的评论:
您的问题就在这里:
$user = User::where('id', $id) // Here more specifically, Laravel does not know if you mean id of users table or details table
->leftJoin('user_details', user_details.user_id', '=', 'users.id')
->first();
像这样重写您的where
语句:
$user = User::where('users.id', $id)....
它应该有效。基本上,由于您要连接 2 个表并且它们都id
因此您需要指定要查询的id
。