© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
SamN

Detach Action Removing every record in Pivot table

My problem is detach action removes every pivot record that has the vehicle_make_id. How can I fix this?

Fitments pivot has a primary id. I expect the detach to use the primary id.

App\Models\Parts.php
class Part extends Model
  { 
  
    public function fitments(): BelongsToMany
  {
         return $this->belongsToMany(VehicleMake::class, 'fitments', 'part_id', 'vehicle_make_id')->withPivot(['vehicle_model_id', 'vehicle_trim_id', 'vehicle_year_id']);
  }
  
  }
class Part extends Model
  { 
  
    public function fitments(): BelongsToMany
  {
         return $this->belongsToMany(VehicleMake::class, 'fitments', 'part_id', 'vehicle_make_id')->withPivot(['vehicle_model_id', 'vehicle_trim_id', 'vehicle_year_id']);
  }
  
  }


PartResource\RelationManagers\FitmentsRelationManager.php;

->actions([
      Tables\Actions\DetachAction::make(),
 ])
->actions([
      Tables\Actions\DetachAction::make(),
 ])
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

Update pivot table when editing record
FilamentFFilament / ❓┊help
2y ago
Dispatch Table Record Action
FilamentFFilament / ❓┊help
3mo ago
Use $record in table action form
FilamentFFilament / ❓┊help
3y ago
Displaying related pivot record details on table
FilamentFFilament / ❓┊help
2y ago