简体   繁体   English

Laravel Spark:将每个用户的团队数量限制为1

[英]Laravel Spark : Limit amount of Teams per user to 1

I'm currently playing around with spark for laravel . 我目前正在为laravelspark 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. 我想将每个用户的团队数量限制为1个。因此,基本上,我想禁止创建新团队或加入其他团队。 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. 通过查看某人在Github上为Spark分叉的代码,看来一个选择就是将用户模型(CanJoinTeams Trait中的代码)与团队模型之间的关系从多对多更改为一对多。将要求您到使用数据透视表中信息的任何位置。

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. 另一种可能的选择是,您可以对一个或两个模型进行检查,以查看用户是否已经属于团队,以及他们是否询问他们是否要更换团队或引发某种错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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