© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
13 replies
core

Creating and updating pivot table with attributes in the relationmanager

I created a IngredientsRelationManager inside the RecipeResource: i see the table fine and get the add new ingredient button and modal:
for some reason it is creating a record in the Ingredients table instead of the pivot recipe_ingredient table.
pivot relationships are
Recipe Model:
public function ingredients()
{
return $this->belongsToMany(Ingredient::class, 'recipe_ingredient', 'recipe_id', 'ingredient_id')
->withPivot('quantity', 'unit');
}

Ingredients Model:

public function recipes()
{
return $this->belongsToMany(Recipe::class, 'recipe_ingredient', 'recipe_id', 'ingredient_id')
->withPivot('quantity', 'unit');
}



code:
{
protected static string $relationship = 'ingredients';

public function form(Form $form): Form
{
$ingredients = Ingredient::all()->pluck('name', 'id')->toArray();

return $form
->schema([
Forms\Components\Select::make('ingredient_id')
->placeholder('Select Ingredients')
->searchable()
->columnSpan(1)
->required()
->options($ingredients),
Forms\Components\TextInput::make('quantity')->default(1),
Forms\Components\TextInput::make('unit')->default('1'),
]);
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Creating with pivot attributes
FilamentFFilament / ❓┊help
2y ago
repeated pivot table records displaying incorrectly in relationmanager table
FilamentFFilament / ❓┊help
7mo ago
HasMany Table Relationship pivot/group RelationManager
FilamentFFilament / ❓┊help
2y ago