我试图创建一条路由来更新mysql表'orcamento'中的信息,但出现此错误
enter code here SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: '$orcamento->id' (SQL: update `orcamento` set `cliente` = joao, `vendedor` = Carlos, `descricao` = 2 peças de vidro, `valor` = 600, `orcamento`.`updated_at` = 2020-08-15 08:15:40 where (`id` = $orcamento->id))
created_at和updated_at由时间戳构建
enter code here {
Schema::create('orcamento', function (Blueprint $table) {
$table->id();
$table->text('vendedor');
$table->text('cliente');
$table->text('descricao');
$table->double('valor',10,2);
$table->timestamps();
});
}
在路由更新中就是这样
public function update(OrcamentoRequest $request, $id)
{
$orcamentos = ModelsOrcamentoModel::where(['id'=>$id])->update([
'cliente'=>$request->cliente,
'vendedor'=>$request->vendedor,
'descricao'=>$request->descricao,
'valor'=>$request->valor
]);
return redirect('cadastros');
}
执行dd函数我得到了
'$orcamentos = ModelsOrcamentoModel::where(['id'=>$id])->dd($id,$request->valor);'
“ $ orcamento-> id” “ 600”
答案 0 :(得分:0)
我以错误的形式传递了网址
<form action="{{url('orcamentos/'.$orcamento->id)}}" name="formEdit" id="formEdit" method="post">