9 months ago

Get all through pivot table

Posted 9 months ago by zefex

I have three tables: User, Subscription (pivot), Plan

When an user buy a plan I add to subscription user_id and plan_id

I was wondering: how can I get all the users that has a subscription for a plan with a name vip? I wanted to do something like: Plan::ofName('vip')->users I don't know if it's possible.

Thank you.

Please sign in or create an account to participate in this conversation.