Laravel: Missing field error in SQL even passing field

Asked

Viewed 42 times

0

I am trying to do an update on Laravel with:

Código para salvar dados no banco

The second line since code was only added to make sure I could pass the date, as it is already being passed through the form, as I could check using dd($request->all())

inserir a descrição da imagem aqui

But when I send the above code it returns: inserir a descrição da imagem aqui

How is this possible? Since it passes through the form can be checked by dd($request->all()), I manually pass the controler as shown in the first image and continue giving this error, how to proceed?

  • The field dat_documento is defined in the respective Model?

  • Yes, you are like: protected $Dates = [ 'dat_document','dat_reply' ];

  • How was created the migration of that input? It appears that no default value has been set for the dat_documento as well as for the dat_resposta.

  • But I created it not to be null! It’s like $table->date('dat_document');. The only difference from the other fields in the table is that it has a ->nullable() in front

  • Try putting in the Model the following, protected $fillable = ['dat_documento']; or if there is already a variable fillable, just add the dat_documento in it.

  • I put along with the other variables in the fillable and picked up... But I’m very curious of the explanation for this. I have two more model that this on the protected date and it worked.... But thanks for the help!

  • Maybe the other Models had their protected $dates as ->nullable() in migrations.

  • Yes, there is, but they are saving and coming out in the report and on the change page. That is, they are saving. Probably the Dates field only works with nullable()...

Show 3 more comments

2 answers

0

Like the field dat_documento was not created as nullable, you need to add the field in the variable protected $fillable.

0

Staff received and helped and came to the following conclusion: On the model was with dat_document and dat_reply within the protected $Dates, I removed the field and put in the fillable and took: inserir a descrição da imagem aqui

The field dat_document is mandatory -not accepted null - and by some Laravel default, protected $Dates only works when the field accepts null. Whether to accept null or not to be set on migration.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.