ExpressionEngine® 3 User Guide

Legacy Documentation

You are using the documentation for version 3.5.17. Go here for the latest version or check here for your available upgrades to the latest version.

Working with Relationships

Setting Relationships

To set a relationship, simply assign the model or collection that you want to relate, and then save() to commit the change:

$member->MemberGroup = ee('Model')->get('MemberGroup', 1)->first();
$member->save();