duanbiaojin8860
2017-06-19 12:41
浏览 142
已采纳

SQLSTATE [HY000]:常规错误:1364字段'reply_text'没有默认值

I have a page that shows a topic, And underneath the topic there are replies. In between these 2, there is a text field where the user can type a reply. The problem is. I get the error in the title when I try to post a reply. I used the same method on a previous project of mine and there it works just fine. How can I solve this?

Here are the files

topic.blade.php

<div class="card">
            <div class="card-content">
                <span class="card-title">Leave a Reply</span>
                <div class="row">
                    <form method="POST" action="{{ route('createreply') }}">
                        {{ csrf_field() }}
                        <input type="hidden" name="user_id" value="{{ Auth::user()->id }}">
                        <input type="hidden" name="post_id" value="{{ $topic->id }}">
                        <div class="form-group col s12">
                            <textarea id="message-body textarea1" class="form-control materialize-textarea" name="reply" placeholder="Type your reply"></textarea>
                        </div>
                        <div class="col s12">
                            <button class="btn right blue-grey darken-4" type="submit">Reply</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

ReplyController.php (Store method)

 public function store(Request $request)
 {
    Reply::create($request->input());

    return back();
 }

Web.php

route::post('/reply/create', 'ReplyController@store')->name('createreply');

Thank you in advance!

图片转代码服务由CSDN问答提供 功能建议

我有一个显示主题的页面,在主题下面有回复。 在这两者之间,有一个文本字段,用户可以在其中键入回复。 问题是。 当我尝试发布回复时,我在标题中收到错误。 我在我之前的一个项目中使用了相同的方法,并且在那里工作得很好。 我该如何解决这个问题?

以下是文件

topic.blade.php

 &lt; div class =“card”&gt; 
&lt; div class =“card-content”&gt; 
&lt; span class =“card-title”&gt;发表回复&lt; / span&gt; 
&lt;  div class =“row”&gt; 
&lt; form method =“POST”action =“{{route('createreply')}}”&gt; 
 {{csrf_field()}} 
&lt; input type =  “hidden”name =“user_id”value =“{{Auth :: user() - &gt; id}}”&gt; 
&lt; input type =“hidden”name =“post_id”value =“{{$ topic  - &gt; id}}“&gt; 
&lt; div class =”form-group col s12“&gt; 
&lt; textarea id =”message-body textarea1“class =”form-control materialize-textarea“name =  “回复”占位符=“输入您的回复”&gt;&lt; / textarea&gt; 
&lt; / div&gt; 
&lt; div class =“col s12”&gt; 
&lt; button class =“btn right blue  -grey darken-4“type =”submit“&gt;回复&lt; / button&gt; 
&lt; / div&gt; 
&lt; / form&gt; 
&lt; / div&gt; 
&lt; / div&gt; 
&lt;  /div>

ReplyController.php(存储方法)

 公共功能存储(请求$请求)\  n {
 Reply :: create($ request-&gt; input()); 
 
返回back(); 
} 
   
 
 

Web。 php

  route :: post('/ reply / create','ReplyController @ store') - &gt; name('createreply'); 
  <  / pre> 
 
 

提前谢谢!

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题