[英]No query results for model [App\Models\XXXX]
I'm getting this error message when updating the data via the PUT method on Postman.通过 Postman 上的 PUT 方法更新数据时,我收到此错误消息。
No query results for model [App\Models\Post].
Code代码
public function store(Request $request)
{
$post = $request->isMethod('put') ? Post::findOrFail
($request->post_id): new Post;
$post->id= $request->input('id');
$post->title= $request->input('title');
$post->body= $request->input('body');
if($post->save()){
return response($post);
}
}
Reference: https://github.com/Devgroup-Asia/lumenblog/blob/main/app/Http/Controllers/PostsController.php参考: https://github.com/Devgroup-Asia/lumenblog/blob/main/app/Http/Controllers/PostsController.php
The issue is due to this below code.问题是由于以下代码引起的。
Post::findOrFail($request->post_id)
Post with $request->post_id doesnot found.找不到带有 $request->post_id 的帖子。 You may be missing to send post_id from form
您可能缺少从表单发送 post_id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.