Interact with Pivot attributes in Relation Manager
I wanted to update the
is_active but it is not updating. not sure what i did wrong here.Department model:
is_activeTables\Columns\ToggleColumn::make('is_active')
->label(__('department.attributes.is_active'))
->onIcon('heroicon-o-eye')
->offIcon('heroicon-o-eye-slash')public function userHasDepartments(): BelongsToMany
{
return $this->belongsToMany(User::class, 'user_has_department')
->withPivot(['is_active'])
->withTimestamps();
}Tables\Columns\ToggleColumn::make('is_active')
->getStateUsing(fn ($record) => $record->pivot->is_active) <--- add this
->sortable()
->onIcon('heroicon-o-eye')
->offIcon('heroicon-o-eye-slash')
->label('Status'),