SQLSTATE [42S22]:找不到列:1054 未知列“_method”

SQLSTATE[42S22]: Column not found: 1054 Unknown column '_method'

我真的不明白为什么这个 @method('PUT') 在我的 SQL 中做未知列 '_method'。我将在下面向您展示可能导致此错误的所有代码。 Laravel 版本 6.2。

SQLSTATE[42S22]: Column not found: 1054 Unknown column '_method' in 'where clause' (SQL: update setups set _method = PUT, id = 1, image = admitad-e1504616712278.png, meta_title = testing, address = testing, contact = testing@testing, email = testing, social = ["testing","testing"], updated_at = 2019-12-29 15:40:21 where _method = PUT)

2019_12_23_171326_create_setups_table.php

public function up()
    {
        Schema::create('setups', function (Blueprint $table) {
            $table->increments('id');
            $table->string('image')->nullable();
            $table->string('meta_title');
            $table->string('address');
            $table->string('contact');
            $table->string('email');
            $table->string('social');
            $table->timestamps();
        });
    }

edit.blade.php

<form class="card-body" method="POST" action="{{ route('setups.update', $data->id) }}">
  @csrf
  @method('PUT')
<input type="hidden" name="tbl" value="{{encrypt('setups')}}">
<input type="hidden" name="id" value="{{ $data->id }}">

  <div class="col-sm-3">
    <div class="form-group" style="left: 5px; padding: 30px 0 30px">
      <input type="file" accept="image/*" name="image" id="file" onchange="loadFile(event)" style="display: none">
      <img id="output" width="150" style="box-shadow: 0px 16px 18px -4px rgba(0,0,0,0.17);"/>
      <label class="card-title" for="file" style="cursor: pointer; padding: 10px 0 0px">Upload Logo</label>
    </div>
  </div>
    <div class="row">
      <div class="col-md-12">
        <div class="form-group">
          <label class="bmd-label-floating">Site title</label>
          <input type="text" name="meta_title" value="{{ $data -> meta_title }}" class="form-control">
        </div>
      </div>
      <div class="col-md-6">
        <div class="form-group">
          <label class="bmd-label-floating">Address</label>
          <input type="text" name="address" value="{{ $data -> address }}" class="form-control">
        </div>
      </div>
      <div class="col-md-6">
        <div class="form-group">
          <label class="bmd-label-floating">Contant number</label>
          <input type="email" name="contact" value="{{ $data -> contact }}" class="form-control">
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <div class="form-group">
          <label class="bmd-label-floating">Email</label>
          <input type="text" name="email" value="{{ $data -> email }}" class="form-control">
        </div>
      </div>
      </div>
    <div class="row">
      <div class="col-md-12" id="socialGroup">
        @foreach($socials as $social)
        <div class="form-group socialField">
        <label class="bmd-label-floating">Social Links</label>
          <input type="text" name="social[]" value="{{ $social }}" class="form-control">
          <a href="#" class="addField"><i class="fa fa-plus"></i></a>
        </div>
        @endforeach
        <div class="alert alert-danger" id="socialError">
        <p><strong>Sorry! </strong>You've reached the max number for social links form.</p>
        </div>
      </div>
    </div>
    <button type="submit" class="btn btn-primary pull-right">Update Profile</button>
    <div class="clearfix"></div>
  </form>

SetupController.php

public function update(Request $request, Setup $setup)
{
    $data = Input::except('_token', 'submit');
    $tbl = decrypt($data['tbl']);
    unset ($data['tbl']);

    if(!empty($data['image'])){
      if(Input::hasFile('image')){
        $data['image'] = $this->upload($data['image'], $tbl);
      }
    }

    $data['updated_at'] = date('Y-m-d H:i:s');
    DB::table($tbl)->where(key($data), reset($data))->update($data);

    session::flash('message','SetupController updated successfully!!!');
    return redirect()->route('setups.index');
}

web.php

路线::资源('setups','SetupController');

@method('PUT') 

总是打印

<input name="_method" type="hidden" value="PUT">

进入源代码 html,如果您不想使用它,您可以删除或删除它们,在您的代码中再添加一个值:

$data = Input::except('_token', 'submit','_method');