FilamentF
Filament7mo ago
Andrew

Column Not Found SQL ERROR

Hello, i'm using Filament 3.3. I have 3 tables in database ("employees", "departments" and a pivot table "department_employee"). I have a belongsToMany relationship in "Employee" and in "Department" models. I also have a pivot table "department_employee" that joins two tables. When I fill out the form "create employee" and enter data into the database, i get the error message:

Error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'departments' in 'field list' (Connection: mysql, SQL: insert into `employees` (`last_name`, `first_name`, `middle_name`, `email`, `IP`, `departments`, `updated_at`, `created_at`) values (Doe, John, Thomas, john@example.com, 192.168.1.26, 11, 2025-06-18 09:37:29, 2025-06-18 09:37:29))
Solution
try ->multiple() for BelongsToMany relationships in the Select component
https://filamentphp.com/docs/3.x/forms/fields/select#integrating-with-an-eloquent-relationship
Was this page helpful?