Sqlstate hy000 general error 1364

I’m new to Laravel and trying to add Product under Category but when I add Product then it shows this error:

SQLSTATE[HY000]: General error: 1364 Field ‘category_id’ doesn’t have a default value (SQL: insert into products . "

Initially i was adding these products without under any category than it was working and now its not adding under Category.

can anyone would prefer to provide me its solution?

here is my form:

here is ProductsController:

Please sign in or create an account to participate in this conversation.

четверг, 14 декабря 2017 г.

Решение: General error: 1364 Field ‘MyField’ doesn’t have a default value

В результате увидите что-то вроде:

STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION

Вот он тот самый STRICT_TRANS_TABLES.
Данный режим выдает ошибки, когда вы пытаетесь добавить в базу записи, не указывая данные объявленные в таблице по умолчанию.
Для отключения нужно выполнить следующий запрос:

I’m staring with Laravel and I’m having troubles trying to make a simple insert, but It seems that all of my fillable fields are not being included. This is the error:

As you can see, only created_at and updated_at are about to be inserted, I thought that maybe I forgot my fillable vars, but this is my Model:

And the Controller

Echo the request() values works! So I’m missing right now, I have some other Models and Controller working good in the same way. Please Help!

Rate this post
Читайте также:  Kyocera 1125 добавьте тонер

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *