Skip to content

Conversation

themsaid
Copy link
Member

@themsaid themsaid commented Aug 3, 2017

This adds the ability to define a belongsToMany relation like this:

public function podcasts()
{
    return $this->belongsToMany(Podcast::class, 'users_podcasts', 'user_id', 'podcast_id')
        ->as('subscription');
}

Now you'll be able to access the pivot data using $podcast->subscription instead of $podcast->pivot.

@ntzm
Copy link
Contributor

ntzm commented Aug 3, 2017

Never knew I wanted this until now, nice one 👍

@antonkomarev
Copy link
Contributor

Thank you for such great addition!

@taylorotwell taylorotwell merged commit e2ebd5b into laravel:master Aug 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants