User registration with field for team/tenant name

Most approaches I found use the 'event(new Registered($user));' to trigger a listenerer that create a personal team after and generate the team's name from the user's name. This is a clean approach. I want the user to specify the team's name during registration and ask some additional questions (business category) during signup. Extending the registration form with these field has been done. What is the cleanest approach to store the team related data given the 'Register.php' functionality?
7 Replies
Matthew
Matthew5d ago
child table
drsdre
drsdreOP5d ago
Not sure what you mean with child table.
Matthew
Matthew5d ago
A table containing the columns with the data you wish to store, with a foreign key to the user\team table. Maybe I misunderstood your question.
drsdre
drsdreOP5d ago
It's a (multi-)tenant setup. The user and team tables are in place. The question is about keeping the functionality in the 'register()' function in Filament\Pages\Auth\Register.php and also have the ability to update the team related fields. The approach I'm currently looking at is using the mutateFormDataBeforeRegister() function to filter out the fields meant for the teams table and overloading the 'register()' function by updating the team model using Filament::getTenant(). This means however that the team model requires two database interactions (create and update).
toeknee
toeknee5d ago
So do exactly what you have but wrap the fields in a Group::make([])->relationship(TeamRelationshop) then it will create it automatically. Because it's a relationship..
drsdre
drsdreOP5d ago
This is the registration i.e. create form where both user and team are created. There is no relationship because there are no records at that point.
toeknee
toeknee4d ago
There isn't but the model is still related. So therefore it is a relationship, the difference is it's a created when you se tthe field as a relationship

Did you find this page helpful?