ExpressionEngine® User Guide

Legacy Documentation

You are using the documentation for version 4.3.8. Go here for 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();