简体   繁体   中英

LARAVEL : SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value

I was trying creating a route to update the information in mysql table 'orcamento' and i am getting this error

   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))

the created_at and updated_at are builded by timestamps

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();
    });
}


    

in route update is like this

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');
    }

Executing the dd function i got this

'$orcamentos = ModelsOrcamentoModel::where(['id'=>$id])->dd($id,$request->valor);' 

"$orcamento->id" "600"

I was passing a wrong url in the form

 <form action="{{url('orcamentos/'.$orcamento->id)}}" name="formEdit" id="formEdit" method="post">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM