Back

Does anyone use Laravel Pennant to store user settings? For example, I have a multi-tenant app and a user can belong to multiple tenants. I want to store which tenant is currently the user's active tenant. Does that make sense or is that best left out of Pennant?

1

172

In response to @skegel

I'd advise against this. Pennant's data is really only a cache of the current state of its rules and can be purged.

For your case I'd recommend a simple foreignId on your users table such as current_tenant_id

2

361

  • No matching results...
  • Searching...

/ 1000

That’s what I was worried about. Thanks for the response! I was also thinking about adding it as a pivot value on the tenant _user table. I try to keep the user table from getting too many extra columns. I could be overthinking it in the case though.

1

189

If you put it on the pivot table, how will you tell which tenant-user combination is the authoritative one that represents the current one?

1

345

The pivot would have a `is_current` field on it so you would look for tenants for the user with `is_current` set. However, that requires the extra work of deselecting the previous one. Though, maybe that’s solved by using a timestamp instead.

1

136

Sounds over-engineered. A simple foreignId on the users table would see this done clearly and concisely

379

Agree with Simon. If the user can control the settings, like they can update their options via a UI, it probably does not belong in Pennant.

181