danw0921
danw0921
FFilament
Created by danw0921 on 8/2/2023 in #❓┊help
Call to undefined method using Relation Manager Attach
@pboivin You're right, it turns out I did need the inverse relationship. In Exercise.php model I added:
public function exercisesRelatedTo(): BelongsToMany
{
return $this->belongsToMany(Exercise::class, 'related_exercises', 'related_exercise_id', 'exercise_id');
}
public function exercisesRelatedTo(): BelongsToMany
{
return $this->belongsToMany(Exercise::class, 'related_exercises', 'related_exercise_id', 'exercise_id');
}
And in RelatedExercisesRelationManager.php I added
public function table(Table $table): Table
{
return $table
...
->inverseRelationship('exercisesRelatedTo');
}
public function table(Table $table): Table
{
return $table
...
->inverseRelationship('exercisesRelatedTo');
}
I'm not entirely sure why this is needed, but it works! I can now search and attach in the modal as expected. Thank you for your help.
9 replies
FFilament
Created by danw0921 on 8/2/2023 in #❓┊help
Call to undefined method using Relation Manager Attach
@pboivin - thanks for getting back to me. I do feel like I've missed something so obvious that I just can't see it! Here's the error page -
9 replies