简体   繁体   中英

Laravel Spark : Limit amount of Teams per user to 1

I'm currently playing around with spark for laravel . I'd like to limit the amount of teams per user to 1. So basically I wantto forbid to create new teams or join other teams. I found the

CanJoinTeams Trait

But I'm actually not sure where to keep looking for changes. I'd love if someone could tell me where I have to look at and where I could overwrite necesseray functions.

By looking at code that someone forked on Github for Spark, it looks like one option is going to be to change that relationship between the User Model (code in CanJoinTeams Trait) and the Teams Model from Many to Many to One to Many, which is going to require you to any spot that uses information in the pivot table.

Another, possible option is that you perform a check in one or both models to see if the user already belongs to a team and if they do either ask if they want to change teams or throw some kind of error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM