Checkbox list relationship data
Hey everyone this is such a great pacakge by the way its pretty impressive, im just having a little issue with my panel if anyone can give me some help.
I created a user panel where you can create, edit and ect like the docs said.
I have now wanted to add some logic into a checkboxlist so that a user can be added to teams that belong to an organisation
Below is my code
Forms\Components\CheckboxList::make('teams')
->options(fn(Forms\Get $get): Collection => $get('organisation_id') ?
Team::whereHas('organisations', function ($subquery) use ($get) {
$subquery->where('id', $get('organisation_id'));
})->pluck('name', 'id') :
collect([]))
Im cursious to know if there could be a better way then doing this ?
Only because im having an issue when I view the user its not showing the teams that they are now assigned to...
If you need more details on Model Relationships and ect I can send them if needed π
Thanks in advance
Wazza0 Replies