belongsTo() public method

BelongsTo assumes that the localKey will reference the foreignEntity's primary key. If this is not the case, you probably want to use the 'hasOne' relationship instead.
public belongsTo ( EntityInterface $entity, $foreignEntity, $localKey )
$entity EntityInterface
Example #1
0
 public static function relations(Mapper $mapper, Entity $entity)
 {
     return ['tags' => $mapper->hasManyThrough($entity, 'SpotTest\\Entity\\Tag', 'SpotTest\\Entity\\PostTag', 'tag_id', 'post_id'), 'comments' => $mapper->hasMany($entity, 'SpotTest\\Entity\\Post\\Comment', 'post_id')->order(['date_created' => 'ASC']), 'author' => $mapper->belongsTo($entity, 'SpotTest\\Entity\\Author', 'author_id')];
 }
Example #2
0
 public static function relations(Mapper $mapper, Entity $entity)
 {
     return ['event' => $mapper->belongsTo($entity, 'SpotTest\\Entity\\Event', 'event_id')];
 }
Example #3
0
 public static function relations(Mapper $mapper, Entity $entity)
 {
     return ['post' => $mapper->belongsTo($entity, 'SpotTest\\Entity\\Post', 'post_id'), 'tag' => $mapper->belongsTo($entity, 'SpotTest\\Entity\\Tag', 'tag_id')];
 }