Rainier laan
Rainier laan

Reputation: 1130

SQLSTATE[HY000]: General error: 1364 Field 'reply_text' doesn't have a default value

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!

Upvotes: 0

Views: 723

Answers (1)

Exprator
Exprator

Reputation: 27513

<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

Upvotes: 1

Related Questions