【发布时间】:2018-10-02 09:30:42
【问题描述】:
无法弄清楚为什么我会收到此错误?我正在使用 posgres 我觉得我错过了一些重要的链接来解决整个问题? 基本上我需要将评论链接到带有 id 的博客文章
SQLSTATE[22P02]:文本表示无效:7 错误:输入无效 整数语法:"{blog}" (SQL: select * from "blogs" where "id" = {blog} 限制 1)
评论控制器
use App\Blog;
use App\Comment;
class CommentsController extends Controller
{
// add store method
public function store(Blog $blog)
{
Comment::create([
'body'=> request('body'),
'blog_id' => $blog->id
]);
return back();
}
}
web.php
Route::post('blog/{blog}/comments', 'CommentsController@store');
带有请求的表单头:
<form method="POST" action="/blog/{blog}/comments">
【问题讨论】:
-
听起来
{blog}没有被转换成整数?可以查一下吗? -