© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•11mo ago•
2 replies
ffffer.

Relation Manager with repeater and pivot

I Hi, I have the following:

class RewardsRelationManager extends RelationManager {
    protected static string $relationship = 'rewards';
[....]
                 Forms\Components\Repeater::make('currencies')
                        ->relationship()
                        ->schema([
                            Forms\Components\Select::make('currency_id')
                                ->label('Currency')
                                ->options(fn () => \App\Models\Currency::pluck('name', 'id'))
                                ->required(),
                            Forms\Components\TextInput::make('amount')
                                ->numeric()
                                ->required()
                                ->minValue(1)
                                ->label('Amount'),
                        ])
class RewardsRelationManager extends RelationManager {
    protected static string $relationship = 'rewards';
[....]
                 Forms\Components\Repeater::make('currencies')
                        ->relationship()
                        ->schema([
                            Forms\Components\Select::make('currency_id')
                                ->label('Currency')
                                ->options(fn () => \App\Models\Currency::pluck('name', 'id'))
                                ->required(),
                            Forms\Components\TextInput::make('amount')
                                ->numeric()
                                ->required()
                                ->minValue(1)
                                ->label('Amount'),
                        ])


In the Reward model:

    public function currencies()
    {
        return $this->belongsToMany(Currency::class)
                    ->withPivot('amount');
    }
    public function currencies()
    {
        return $this->belongsToMany(Currency::class)
                    ->withPivot('amount');
    }


The migration of the pivot is:

        Schema::create('reward_currency', function (Blueprint $table) {
            $table->foreignId('reward_id')->constrained('rewards')->onDelete('cascade');
            $table->unsignedTinyInteger('currency_id');
            $table->foreign('currency_id')->references('id')->on('currencies')->onUpdate('cascade');
            $table->unsignedInteger('amount')->nullable();
            $table->primary(['reward_id', 'currency_id']);
        });
        Schema::create('reward_currency', function (Blueprint $table) {
            $table->foreignId('reward_id')->constrained('rewards')->onDelete('cascade');
            $table->unsignedTinyInteger('currency_id');
            $table->foreign('currency_id')->references('id')->on('currencies')->onUpdate('cascade');
            $table->unsignedInteger('amount')->nullable();
            $table->primary(['reward_id', 'currency_id']);
        });


The data in pivot, is shown in the repeater, no problem at all. But when I try to update or create data, there is no changes or rows created in the database.

I tried some approachs with mutateRelationshipDataBeforeSaveUsing, but no luck. Any ideas?

Thanks
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Relation Manager with Pivot and ordering on pivot
FilamentFFilament / ❓┊help
3y ago
Relation Manager + Repeater?
FilamentFFilament / ❓┊help
3y ago
Issue with Pivot relation on Repeater
FilamentFFilament / ❓┊help
3y ago
Relation Manager for pivot table
FilamentFFilament / ❓┊help
2y ago