Skip to content
Advertisement

Laravel I added morphmany SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘staff.staff_id’ in ‘field list’

I store the data correctly but when I try to get a data in edit function it shows me this error

SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘staff.staff_id’ in ‘field list’ (SQL: select users.*, staff.staff_id as pivot_staff_id, staff.user_id as pivot_user_id, staff.staff_type as pivot_staff_type, staff.role as pivot_role, staff.created_at as pivot_created_at, staff.updated_at as pivot_updated_at from users inner join staff on users.id = staff.user_id where staff.staff_id in (2) and staff.staff_type = AppModelsInvestor)

JavaScript

Advertisement

Answer

you don’t follow naming conventions so you should determine the foreign key and "other key" for the relationship:

JavaScript

I don’t know your table columns name but in your case can be something like below:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement