I am using Teams in Spark but without Team Billing. A user can create as many teams as they want - but it is an optional thing and not required when they first start using the app.
What I would like to be able to configure is that when a user first registers, a Team is created but just with the same name as the user and that this particular team will only ever have a maximum of one user.
That way I can keep all logic throughout the app based on Teams.
What's the best way to approach adding the team creation to the registration process without making future upgrades more difficult then necessary?
// app/User.php
protected $dispatches = [
'created' => UserCreatedEvent::class,
];
// app/Providers/EventServiceProvider.php
protected $listen = [
UserCreatedEvent::class => CreateTeamListener::class,
];
// app/Listeners/CreateTeamListener.php
// in handle method just create new team for that user and that is it
Observers:
// let me know if you do not want to use events
I love events more since they have specific reusable chunks, while observers can get messy and huge.