Pls Help Me
Error “SQLSTATE[HY000]: Column ‘name’ does not have a default value” when creating/updating data with Filament Repeater (Laravel BelongsToMany)
Hello fellow developers,
I am developing a cashier application using Laravel and FilamentPHP. I am encountering an “Internal Server Error” with the specific message SQLSTATE[HY000]: General error: 1364 Field ‘name’ doesn't have a default value when trying to create or update cashier data that has a relationship with the menu through Filament Repeater.
I have two main models, Cashier and Menu, which have a Many-to-Many relationship (BelongsToMany). To manage this relationship in the Filament admin panel, I use Forms\Components\Repeater::make(‘menus’)->relationship(‘menus’) within KasirResource.php. This repeater allows me to select menu_id and enter quantity for each menu associated with the cashier order.
-
When Creating a New Cashier: Although the error
SQLSTATE[HY000]: General error: 1364 Field ‘name’ doesn't have a default valueappears, the cashier data (and its menu relationship) is saved to the database. This is somewhat confusing, as such errors typically fail the operation. -
When Updating an Existing Cashier: When I attempt to edit existing cashier data, the exact same error (
SQLSTATE[HY000]: General error: 1364 Field ‘name’ doesn't have a default value) appears, and the update operation fails. -
Creating the
kasir_menupivot table:*I have created a migration for thekasir_menupivot table containingkasir_id,menu_id, andquantity. I have also confirmed that this migration was successfully executed (when runningphp artisan migrate, I received the messageTable ‘kasir_menu’ already exists, indicating the table already exists).
Please or to participate in this conversation.