Skip to content
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

Eloquent Resource whenPivotLoaded doesn't work when using custom accessor #25596

Closed
GeorgThomassen opened this issue Sep 12, 2018 · 0 comments
Closed

Comments

@GeorgThomassen
Copy link

GeorgThomassen commented Sep 12, 2018

  • Laravel Version: 5.7.2
  • PHP Version: 7.2.9
  • Database Driver & Version: MariaDB 10.3.9

Description:

When using the ->whenPivotLoaded method on a Resource where the underlying Eloquent model has aliased the pivot accessor with ->as('accessor') no value is returned. ConditionallyLoadsAttributes.php only tries to access the pivot table using ->pivot which is null after changing the accessor.

Steps To Reproduce:

Create two models in a many-to-many relationship.
Eager load the relationship.
Change the accessor of the pivot table with the ->as() method.
Create a Resource and return a value based on whenPivotLoaded

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

No branches or pull requests

1 participant