.jw.
Accessing pivot model relationships in relationship manager
I have a relationship manager that handles a belongsToMany that is defined with
using(SomePivotModel::class)
. The pivot model has a couple of belongsTo relationships defined. The belongsToMany relationship allows duplicates. If I don't have allowDuplicates()
set on the relationship manager table, then I can pull in data from the pivot model relationships in my columns (using a format like pivot.somerelationship.name
). If I set the table to allowDuplicates()
, I can no longer access those pivot relationships. I can access the other columns in the pivot table, though they are no longer available as pivot.somefield
, they are just at the top level. I see in the Filament code that this is because of a longstanding bug in Laravel about how it handles IDs in eloquent, though I'm not completely following the fix. I'm wondering if anyone else has run into this or has an idea of how I can access those pivot relationships when allowDuplicates()
is set.3 replies