Closed TheFrankman closed 4 years ago
For the second relationship, you need to swap the last foreign and local key:
class Playlist extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function storages(): HasManyDeep
{
return $this->hasManyDeep(
Storage::class,
['item_playlist', Item::class],
[null, null, 'id'],
[null, null, 'storage_id']
);
}
}
You sir, are a fantastic human! Works perfectly.
Firstly, thank you for the package. Secondly, thank you for your quick reply!
Hello There,
I'm using your repo to get a relationship, and i'm really struggling using it for the inverse, wondering if you could provide some assistance.
I've attached an image that explains it best. Top digram is the one that's working, bottom is the one i'm yet to figure out
To elaborate further this is storage -> playlist which is working (thanks!)
The above works because storage HasMany items and Items BelongToMany playlists.
The inverse : as playlist belongsToMany items and an item BelongsTo storage.
So I believe what i'm looking for is BelongsTo through belongsToMany ?