Laravel: Get pivot data for specific many to many relation
On the relationships for both User and Target, tack on a ->withPivot(‘type’) which will instruct Laravel to include that column. Then once you have your result set, you can access the field with $user->pivot->type. If you’re not iterating over a collection, but have a user and one of their targets and want the type field, … Read more