Hi all- this is probably only partially CI related, but since CI4 is introducing me to Entities for the first time I figured it might others as well. I'm wondering what the best practice is for an entity handling its pivot table(s)? Consider this example:
USERS
id, firstname, lastname, email, deleted, created_at, updated_at
WIDGETS
id, name, color, deleted, created_at, updated_at
USERS_WIDGETS
user_id, widget_id, created_at
My simple User model return type is 'App\Entities\User', and my user Entity handles the normal stuff. Now, am iterating through $users->findAll() and want to display each user's widgets. In CodeIgniter 3 I would have a function in my user model $this->User->widgets($user->id) that returned widget_id from users_widgets, and then could use $this->Widget->get($widget_id) if I needed the whole row.
The same could be accomplished in my entity by defining getWidgets() and then I could use $user->widgets - is that how folks typically do it? Or other recommendations / example repos to check out? Do people pass around IDs or entire data rows (e.g. does getWidgets() return an int or an object/array)?
Thanks for the help!