New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Allow custom pivot accessors #20411

Merged
merged 1 commit into from Aug 4, 2017

Conversation

Projects
None yet
4 participants
@themsaid
Member

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

This comment has been minimized.

Show comment
Hide comment
@ntzm

ntzm Aug 3, 2017

Contributor

Never knew I wanted this until now, nice one 👍

Contributor

ntzm commented Aug 3, 2017

Never knew I wanted this until now, nice one 👍

@antonkomarev

This comment has been minimized.

Show comment
Hide comment
@antonkomarev

antonkomarev Aug 4, 2017

Contributor

Thank you for such great addition!

Contributor

antonkomarev commented Aug 4, 2017

Thank you for such great addition!

@taylorotwell taylorotwell merged commit e2ebd5b into laravel:master Aug 4, 2017

2 checks passed

continuous-integration/styleci/pr The StyleCI analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment