Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jwheat's avatar

Adding a column to the teams table

Short version - How do you extend the teams table? I've added a column to the teams table and can't seem to save data to it when I create a new team.

Long version - I've taken Spark and made it even more multi-tennant using a CNAME for my clients, who can then have teams, etc. This was necessary, I'm not just bored :)

To get this to work - I added a clients table and client_id fields to my users and teams table.

When the owner signs up, a new record is created in the clients table and thus a client_id. I can't figure out how to get it saved to the teams table.

I've tried hacking up TeamController.php (yea I know this is in the src tree and will get overwritten) Anyway right before the CreateTeam call, I add client_id to the request variable with

$request->request->add(['client_id' => Auth::user()->client_id]);

this works and can see it if I dd($request)

I also edited the model - Team.php and added 'client_id' to the $fillable

but I still get the error: Field 'client_id' does not have a default value

Which means to me that the model isn't accepting (or seeing) the client_id I have in $request.

Any ideas how to extend the Teams model? (and if there's a proper way to do this that will outlive an update).

Thanks

0 likes
2 replies
jwheat's avatar

@KEL_ - Thank you @kel_. I remember seeing that topic in my searches, but in my mind it said "Registration" and wasn't what I was looking for, so I skipped past it. Stupid brain, sorry.

I learned SO much from that post too. Between Spark::swap and copying the entire file to a SparkExtensions directory and activating it in the SparkServiceProvider.

I ended up getting it to work with Spark::swap, works beautifully.

Thanks again for redirecting me over there.

Please or to participate in this conversation.