How can I work with related entries within a Matrix in a plug in? I have a Matrix field named "skillLevels" with a single block type.
Each row has 2 fields, "skillName" and "skillLevel"

skillName is a relationship to another entry (Skills)
skillLevel is a simple integer.

I am building a custom plugin which takes post data from a form.
The form contains an entry ID ($groupId), a skill name and a value to use to modify the level of that skill.

$groupEntry = craft()-&gt;entries-&gt;getEntryById($groupId);

    $skillLevels = $groupEntry-&gt;skillLevels;

    foreach($skillLevels as $skill){
       $skillLevel = $skill-&gt;skillLevel; // outputs the skill level
       $skillName = $skill-&gt;skillName; // this doesn't work
    }


$skill-&gt;$skillLevel gives me the integer stored in that field.
But $skill-&gt;skillLevel does not gives me a model. I then tried using $skill->skillLevel->id but still no luck.

How can I look through the Matrix rows to find the row that matches the skill name coming from the form Post data?
It’s an entries field, so $skill-&gt;skillName returns just the ElementCriteriaModel prepared to query for one or more elements matching the criteria.

You need to do something like this:

$entry = $skill-&gt;skillName-&gt;first();
$skillName = $entry ? $entry-&gt;title : null;