Support the ongoing development of Laravel.io →
Database Architecture

We are creating an application which will share objects with other users in the same group. For instance, when object A is created by user 1, and user 2 is added to the same group, the object A has to be available for user 2.

Currently, the user_id is saved for the objects, and there are found based on this ID:

$q = A::where('user_id', Auth::$user->id); return $q->get();

However, we want to return al the objects from A from all the users who are in a group. My instinct would to make a user_group table and a usergroups table to link users to each other and replace Auth::$user->id with all id's from the group(s) the user is in. But is that the optimal method, from an performance perspective?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.