Support the ongoing development of Laravel.io →
Eloquent Laravel

Hi,

I have a many to many relation between users and groups. The pivot table features a from and to fields which say, between which dates a user is in a group. That way, I can keep track, in what group a user was. For that reason, a user can relate to the same group multiple times, but for different timespans. On an eloquent model, i can use the sync() which only accepts an id once. Also attach() and detach() have an id as argument. How should I save related models then, if I cannot use mentioned methods? Only way I see right now is to omit relationship properties and use a pivot model instead and do all the syncing manually. Or do I miss something?

Thanks, Simon

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Simon Bösch iamsab Joined 2 May 2024

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.