0

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.

Amarnasan
  • 14,939
  • 5
  • 33
  • 37
Frnak
  • 6,601
  • 5
  • 34
  • 67

1 Answers1

0

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.

Infernobass7
  • 129
  • 2
  • 7
  • Thanks ! But I have another question : the model of the team / user is using a trait. The trait is in the vendor folder. If I change something in the trait - it will be overwritten in the next update right ? Where exactly would I place my code to ensure it's not overwritten – Frnak May 23 '16 at 06:11
  • I am not sure if the trait will be overwritten or not, but this is provided in the Spark Documentation:
    >This command will download and install the latest release of Spark into your application and update any views that have not already been customized. Views that have already been customized will not be updated.
    If you place the code that is in the trait and you do not want to lose in your model, you should be good.
    – Infernobass7 May 23 '16 at 15:33