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 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']]);
                }),


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 ?
Was this page helpful?