Open dgironella opened 2 weeks ago
Could you provide a demo repo?
Could you provide a demo repo?
Not at this time, I need to create it. My repo is not public.
If you could make something similar so i can test it that would be great!
I think that problem is in line 119 on filament-select-tree > src > SelectTree.php when sync is called on relationship, previous relationships are removed, but I think is a problem from laravel that no respect where clause on relationship on sync call.
For now I solved it overwriting saveRelationshipsUsing function, and detach and attach values. Working but now a clean solution.
// Wrap the state in a collection and convert it to an array if it's not set.
$state = Arr::wrap($state ?? []);
$pivotData = $component->getPivotData();
// Sync the relationship with the provided state (IDs).
if ($pivotData === []) {
$result = $component->getRelationship()->where('tipus', SubCodeEnum::Institucio);
$component->getRelationship()->detach($result->pluck('id')??[]);
$component->getRelationship()->attach($state ?? []);
return;
}
// Sync the relationship with the provided state (IDs) plus pivot data.
$component->getRelationship()->syncWithPivotValues($state ?? [], $pivotData);
}),```
What happened?
If you use two SelectTree with same relationship but a diferent modifyQueyUsing when save only last SelectTree is saved
How to reproduce the bug
And on Client Model relationship
Package Version
3.1
PHP Version
8.2
Laravel Version
11.9
Which operating systems does with happen with?
Linux
Notes
No response