Skip to content

Unknown column 'table_name.user_id' in 'where clause' #161

@iuriemalai

Description

@iuriemalai

I suppose that if we enable the trait and define $softCascade in the User model, in the related model's table the user_id will be searched, and if we will enable it in the Book model, the book_id will be searched. Is that true? Because the model related to the User model, for which I enabled the trait, does not have the user_id column, but it does have the model_id column. And this causes the error below to appear. If I change the column name to user_id everything is OK. Can we somehow override this, indicating when necessary, which column should be searched in a particular case? Maybe in the function defined for the relation?

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'table_name.user_id' in 'where clause'

  • 'table_name' is just a placeholder for the real table name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions