I can't figure out how to save (or retrieve) relationship field data using the Model Service. I can save flat fields with out an issue (and retrieve them).
So when retrieving an entry like this:
$entry = ee('Model')
->get('ChannelEntry')
->filter('channel_id', 1)
->first();
var_dump($entry->field_id_1); // this is a text field data, this works
var_dump($entry->field_id_2); // this is a relationship field with data, it outputs NULL
As you can see, I don't get the relationship data. I couldn't figure out a way to load relationship data either, by using ->with("Relationships")
or any other verbiage that makes sense.
At the same time, I can't seem to save relationship data in any way:
$entry = ee('Model')->make('ChannelEntry');
$entry->title = "Title";
$entry->url_title = "title";
$entry->site_id = 1;
$entry->channel_id = 1;
$entry->status = "open";
$entry->author_id = 1;
$entry->field_id_1 = "My text field"; // this works
$entry->field_id_2 = array("100", "101"); // doesn't save relatoinship data, and trying a few different formats didn't work
$entry->save();
I've been digging through the EE source code and it isn't clear if this is possible at all. I know I could insert raw DB entries next to the Model Service, but that sucks and is harder to get right.
Any one have any success with this?