irankhosravi
1 month ago
171
4
Laravel

Column not found: 1054 Unknown column '_method' in 'field list'

Posted 1 month ago by irankhosravi

I want to update a faq form. but I get this error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column '_method' in 'field list' (SQL: update faqs set _method = PUT, _token = Kz2Wkgd44UA3nOVzmE8PhCGH66ywP296UqUQR8m6, title = q, body =

q

, faqs.updated_at = 2019-09-15 18:55:06 where faqs.user_id = 1 and faqs.user_id is not null)

FaqController.php

public function update(FaqRequest $request, Faq $faq)
{
    auth()->user()->faq()->update($request->all());
    return redirect()->route('faq.index');
}

edit.blade.php

<form action="{{ route('faq.update', $faq->id ) }}" method="post">
    @method('PUT')
    @csrf
    @include('errors.validate')
    <div class="form-group">
        <label for="title">title</label>
        <input type="text" class="form-control col-md-3" id="title" name="title" placeholder="عنوان" value="{{ old('title') ? : $faq->title }}">
    </div>
    <div class="form-group">
        <label for="body">body</label>
        <textarea class="form-control" rows="10" id="body" name="body">{{ old('body')  ? : $faq->body }}</textarea>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-primary">save</button>
    </div>
</form>

User.php

public function faq()
{
    return $this->hasMany(Faq::class);
}

Please sign in or create an account to participate in this conversation.