SQL Error when saving, no such column

I have 3 resources: FoodMenu, FoodMenuSections, FoodMenuItems. A food menu has many sections and a section has many items. I have the section relation manager and the item relation manager set up. The errors When I save a food menu section with the menu set I get the following error
SQLSTATE[HY000]: General error: 1 no such column: menu_id (Connection: sqlite, SQL: update "food_menu_sections" set "menu_id" = 1, "updated_at" = 2025-02-28 15:57:36 where "id" = 6)
SQLSTATE[HY000]: General error: 1 no such column: menu_id (Connection: sqlite, SQL: update "food_menu_sections" set "menu_id" = 1, "updated_at" = 2025-02-28 15:57:36 where "id" = 6)
Then if I look at the database the row is created exactly how I was expecting, with the menu id set under the food_menu_id column. So I don't understand the error as I've not tried to set menu_id and the query seems to work? The same error happens when creating a food menu item
SQLSTATE[HY000]: General error: 1 no such column: section_id (Connection: sqlite, SQL: update "food_menu_items" set "section_id" = 1, "updated_at" = 2025-02-28 16:05:13 where "id" = 11)
SQLSTATE[HY000]: General error: 1 no such column: section_id (Connection: sqlite, SQL: update "food_menu_items" set "section_id" = 1, "updated_at" = 2025-02-28 16:05:13 where "id" = 11)
On both filament resources I am referencing the correct column from the table so I don't know why this error is being thrown? neither menu_id or section_id are referenced anywhere in the code.
1 Reply
Samazer
SamazerOP2mo ago
Here are the resources which are having issues
class FoodMenuSectionResource extends Resource
{
protected static ?string $model = FoodMenuSection::class;

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('food_menu_id')
->relationship('menu', 'name')
->required(),
Forms\Components\TextInput::make('name')->required(),
Forms\Components\Textarea::make('description'),
]);
}
...
}
class FoodMenuSectionResource extends Resource
{
protected static ?string $model = FoodMenuSection::class;

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('food_menu_id')
->relationship('menu', 'name')
->required(),
Forms\Components\TextInput::make('name')->required(),
Forms\Components\Textarea::make('description'),
]);
}
...
}
class FoodMenuItemResource extends Resource
{
protected static ?string $model = FoodMenuItem::class;

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('food_menu_section_id')
->relationship('section', 'name')
->required(),
Forms\Components\TextInput::make('name')->required(),
Forms\Components\TextInput::make('price')->required()->numeric(),
Forms\Components\Textarea::make('description'),
Forms\Components\FileUpload::make('image')->image(),
Forms\Components\Select::make('suitable_for_diet')
->options([
'vegan' => 'Vegan',
'vegetarian' => 'Vegetarian',
'gluten_free' => 'Gluten Free',
])
->nullable(),
]);
}
...
}
class FoodMenuItemResource extends Resource
{
protected static ?string $model = FoodMenuItem::class;

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('food_menu_section_id')
->relationship('section', 'name')
->required(),
Forms\Components\TextInput::make('name')->required(),
Forms\Components\TextInput::make('price')->required()->numeric(),
Forms\Components\Textarea::make('description'),
Forms\Components\FileUpload::make('image')->image(),
Forms\Components\Select::make('suitable_for_diet')
->options([
'vegan' => 'Vegan',
'vegetarian' => 'Vegetarian',
'gluten_free' => 'Gluten Free',
])
->nullable(),
]);
}
...
}

Did you find this page helpful?