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

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!

  • 写回答

1条回答 默认 最新

  • dongyao4419 2017-06-19 12:48
    关注
    <textarea id="message-body textarea1" class="form-control materialize-textarea" name="reply_text" placeholder="Type your reply"></textarea>
    

    Try this. The name attribute was not reply_text as you have in db

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建