php1054,php – 找不到列:1054’字段列表’Laravel中的未知列’_token’

我尝试更新我的表类别的记录,但它向我显示错误

Column not found: 1054 Unknown column ‘_token’

路线

Route::post('/categorias/edit/{id}', 'CategoryController@update');

调节器

public function update(Request $request, $id)

{

$data = request()->all();

Categoria::where('id', '=', $id)->update($data);

return redirect()->to('categorias');

}

模型

class Categoria extends Model

{

protected $table = 'categoria';

protected $fillable = ['id','codigo','nombre','descripcion','estado'];

形成

{{ Form::open(array('url' => url('categorias/add') , 'class'=>'form-horizontal' , 'id' => 'formulario' , 'method' => 'POST')) }}

{{ csrf_field() }}

NO ACTIVO

ACTIVO

Cerrar

Guardar

{{ Form::close() }}

记录在一个表格中,我使用相同的表格进行编辑和添加新记录,只有通过单击编辑按钮,我才能更改动作

$('#formulario').attr('action', '{{ url("categorias/edit")}}'+ "/"+ $('#idcate').val());

解决方法:

你的错误来自

$data = request()->all();

//which includes '_token'

//coming from csrf_field()

相反

$data = request()->except(['_token']);

//same as $request->except('_token');

标签:php,laravel

来源: https://codeday.me/bug/20190713/1445817.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值