I have videos and artists, video belongsTo artist and artist hasMany videos.
I did it and is working, when I find videos and set [contain => ['Artists'] I got the result videos entity with the related artist.
This first relationship is about the artist that is the "owner" of the video, but I need another relationship because a video could have N others artists "featuring" the video.
Heres a better overview:
Tables:
videos: id (pk), artist_id (fk)
artists_videos: video_Id (pk), artist_id (pk)
artists: id (pk)
-
Heres the code:
//VideosTable
$this->BelongsTo('Artists');
$this->belongsToMany('Artists');
//ArtistsTable
$this->hasMany('Videos');
$this->belongsToMany('Videos');
The issue is, when I set this second relationship the first relationship stops to work, I think is happening some kind of collision.