Tuesday, February 28, 2017

Laravel Polymorphic Many To Many Fetch By Specific Association

I have a simple many-to-many polymorphic relationship (if such thing is possible):

Authors

On Blog we have Posts => Authorable On Magazine, Articles => Authorable

Both relationships work as expected/documented. What I need is to fetch All authors for a specific Post Category

All I have is: Post::category('blue') Collection (category being a scope). Based on that, what is the best way to get Authors that wrote "Blue Posts" ?




via Fernando Barrocal

Advertisement