Hi Community,
I have a doubt about relationships, in the documentation they explain how to take advantage of relationships that are assigned in the model via hasMany y belongsTo:
$robot = Robots::findFirst(2);
foreach ($robot->robotsParts as $robotPart) {
echo $robotPart->parts->name, "\n";
}
It works fine, but I want to do the same using Robots:find() and I'm getting an error, why?
$robot = Robots::find();
foreach ($robot->robotsParts as $robotPart) {
echo $robotPart->parts->name, "\n";
}
Hope you can help me, thanks