Home > OS >  Column not found: 1054 Unknown column 'type_id' in 'field list'
Column not found: 1054 Unknown column 'type_id' in 'field list'

Time:10-16

I get this error when i tried to compile the controller of a class named Type in which i tried to create a classs called Compte, the relation is One type to Many compte. Column not found: 1054 Unknown column 'type_id' in 'field list' (SQL: insert into comptes (password, type_id, updated_at, created_at) values (hhh, 1, 2021-10-15 18:16:49, 2021-10-15 18:16:49))

The type_id does not exist in my code: enter image description here

CodePudding user response:

The "type_id" is not a column in the database table you are inserting into.

CodePudding user response:

That was because of you haven't column named type_id in your database table.

CodePudding user response:

you create column name id_type in the database but in model, you named it type_id need to fix it in the data

https://i.stack.imgur.com/ciBt9.png

CodePudding user response:

As you write in your code, you define the id_type column for your table but you try to insert data to type_id column that doesn't exists!

CodePudding user response:

Add field name in model like protected $fillable = ['type_id',....]; Or remove protected $fillable from model then all fields available for fillable

  • Related