© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago
Aziz Trabelsi

ToggleColumn don't update the pivot table

I have 2 tables that they have a BelongsToMany relationship like in below
    public function tests(): BelongsToMany
    {
        return $this->belongsToMany(Test::class, 'company_test')
            ->withPivot('cash_price', 'sponsor_price', 'hc_price', 'transport_price', 'is_active')
            ->withTimestamps();
    }
    public function tests(): BelongsToMany
    {
        return $this->belongsToMany(Test::class, 'company_test')
            ->withPivot('cash_price', 'sponsor_price', 'hc_price', 'transport_price', 'is_active')
            ->withTimestamps();
    }


    public function companies(): BelongsToMany
    {
        return $this->belongsToMany(Company::class, 'company_test')
            ->withPivot('cash_price', 'sponsor_price', 'hc_price', 'transport_price', 'is_active')
            ->withTimestamps();
    }
    public function companies(): BelongsToMany
    {
        return $this->belongsToMany(Company::class, 'company_test')
            ->withPivot('cash_price', 'sponsor_price', 'hc_price', 'transport_price', 'is_active')
            ->withTimestamps();
    }


My ToggleColumn is like this:
            Tables\Columns\ToggleColumn::make('is_active')
                ->label('Active')
                ->action(function (array $data) {
                    \Log::error('Toggle action triggered', $data);
                    $this->company->tests()->updateExistingPivot($data['test_id'], ['is_active' => $data['is_active']]);
                }),
            Tables\Columns\ToggleColumn::make('is_active')
                ->label('Active')
                ->action(function (array $data) {
                    \Log::error('Toggle action triggered', $data);
                    $this->company->tests()->updateExistingPivot($data['test_id'], ['is_active' => $data['is_active']]);
                }),


Even the log not shown in the log.

I need to to update is_active in the pivot table but it keep updating in tests table.

Any help please ?
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

ToggleColumn Pivot
FilamentFFilament / ❓┊help
3y ago
Update data on pivot table
FilamentFFilament / ❓┊help
2y ago
Update pivot table when editing record
FilamentFFilament / ❓┊help
2y ago
How to disable ToggleColumn when user don't have update permission
FilamentFFilament / ❓┊help
3y ago