F
Filament2y ago
Gush

RelationManager associate users

Hello, i have a UsersRelationManager and i would like to be able to only associate users with the group_id field null, so i dont steal a user from another organization. How would that be possible?
8 Replies
Dennis Koch
Dennis Koch2y ago
The AssociateAction should have a method to filter the options I think. Or at least to modify the underlying select.
Gush
GushOP2y ago
Tables\Actions\AssociateAction::make() ->options(User::where('group_id', null)) ->disableAssociateAnother() ->preloadRecordSelect(), something like this?
Dan Harrin
Dan Harrin2y ago
you shouldnt need to modify it we will only list users without a group anyway I think
Gush
GushOP2y ago
my "Group" is as of organization
Dan Harrin
Dan Harrin2y ago
?
Gush
GushOP2y ago
Group has many users, it lists all users expect those from the group im editing
Dan Harrin
Dan Harrin2y ago
Tables\Actions\AssociateAction::make()
->modifyRecordSelectOptionsQueryUsing(fn ($query) => $query->where('group_id', null))
->disableAssociateAnother()
->preloadRecordSelect()
Tables\Actions\AssociateAction::make()
->modifyRecordSelectOptionsQueryUsing(fn ($query) => $query->where('group_id', null))
->disableAssociateAnother()
->preloadRecordSelect()
Gush
GushOP2y ago
->recordSelectOptionsQuery(fn ($query) => $query->where('group_id', null))
->recordSelectOptionsQuery(fn ($query) => $query->where('group_id', null))
did the job, i think you wrote the name of the variable instead of the function name
Want results from more Discord servers?
Add your server