staudenmeir / eloquent-has-many-deep

Laravel Eloquent HasManyThrough relationships with unlimited levels
MIT License
2.67k stars 157 forks source link

reverseFromRelationship #163

Closed sbc640964 closed 2 years ago

sbc640964 commented 2 years ago

Feature cabin Do not know if it belongs, but trying to ask The function I am requesting is reverseFromRelationship What I would like, is to get the corresponding function in the associated model and make it for the current model.

Example Fits your first sample in readme:

class Country extends Model
{
    use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

    public function comments()
    {
        return $this->hasManyDeep(Comment::class, [User::class, Post::class]);
    }
}

class Comment extends Model
{
    use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

    public function countries ()
    {
        return $this->hasReverseFromRelationship(Comment::class, 'comments');
    }
}
staudenmeir commented 2 years ago

Interesting idea, I'll look into that.

sbc640964 commented 2 years ago

Thanks It's nice of you to take every request seriously. :)

Successfully, Waiting for feature

staudenmeir commented 2 years ago

I released v1.15.2 with reverse relationships: https://github.com/staudenmeir/eloquent-has-many-deep#reversing-relationships