2017-03-14 4 views
-1

Ich versuche, ein Update mit Laravel 5.1 zu erstellen, aber es zeigt den Fehler:Schwierigkeiten bei der Erstellung von Update mit Laravel 5.1

Ich habe 2 Updates in diesem Verfahren, und ich bemerkte, dass der Fehler geschieht schon in dem ersten

Type error: Argument 1 passed to Illuminate\Database\Eloquent\Builder::update() must be of the type array, null given

Mein -Controller

public function update($id) 
{ 


     $dadosForm = $this->request->except('_token'); 
     $dadosForm = $this->request->offsetUnset('fat_cnpj'); 
     $dadosForm = $this->request->offsetUnset('vatendimento'); 
     $dadosForm = $this->request->offsetUnset('integra'); 
     $dadosForm = $this->request->offsetUnset('material'); 

    $proposta = $this->proposta; 

     $proposta->cliente_id = $this->request->get('cliente_id'); 
     $proposta->contato = $this->request->get('contato'); 
     $proposta->email = $this->request->get('email'); 
     $proposta->telefone = $this->request->get('telefone'); 
     $proposta->fatcnpj = $this->request->get('fatcnpj'); 
     $proposta->atendimento = $this->request->get('atendimento'); 
     $proposta->dt_solicitacao = $this->request->get('dt_solicitacao'); 
     $proposta->dt_vigencia = $this->request->get('dt_vigencia'); 
     $proposta->vendedor = $this->request->get('vendedor'); 
     $proposta->coleta = $this->request->get('coleta'); 
     $proposta->dt_integracao = $this->request->get('dt_integracao'); 
     $proposta->hr_integracao = $this->request->get('hr_integracao'); 
     $proposta->frete_material = $this->request->get('frete_material'); 
     $proposta->status_id = $this->request->get('status_id'); 

     $this->proposta->where('id', $id)->update($dadosForm); 




     $proposta_id = $id; 

     $count = $this->ensaios->max('id'); 


     for($i=1;$i<=$count;$i++){ //Save Ensaios 

     $proposta_ensaios = new PropostaEnsaios(); 

     $proposta_ensaios->id_proposta = $proposta_id; 
     $proposta_ensaios->id_produto = $i; 
     $proposta_ensaios->quantidade = $dadosForm['quantidade_'.$i]; 
     $proposta_ensaios->valor= $dadosForm['valor_'.$i]; 
     $proposta_ensaios->total = $dadosForm['total_'.$i]; 

     $proposta_ensaios->where('id', $id)->update($dadosForm); 

     } 


    $this->request->session()->flash('alert-success', 'Dados Alterados com Sucesso!'); 
    return redirect()->route('manage-content'); 
} 

Antwort

0

Sie sind in den letzten vier Zeilen die $ dadosForm Variable auf NULL setzen:

$dadosForm = $this->request->except('_token'); 
    $dadosForm = $this->request->offsetUnset('fat_cnpj'); 
    $dadosForm = $this->request->offsetUnset('vatendimento'); 
    $dadosForm = $this->request->offsetUnset('integra'); 
    $dadosForm = $this->request->offsetUnset('material'); 

(als Referenz PHP wird ein NULL-Wert von Funktionen geben, die keine Rückkehr geben - wie offsetUnset nicht.) Ich glaube, Sie beabsichtigen, wie etwas mehr zu tun:

$this->request->offsetUnset('fat_cnpj'); 
    $this->request->offsetUnset('vatendimento'); 
    $this->request->offsetUnset('integra'); 
    $this->request->offsetUnset('material'); 

    $dadosForm = $this->request->except('_token'); 
+0

Änderte den Fehler, jetzt ist der Fehler im Array unter Spalte nicht gefunden –

Verwandte Themen