DEV Community

Md Abdullah al noor
Md Abdullah al noor

Posted on

How to filter a pivot table using Eloquent?

How to filter a pivot table using Eloquent?

32

I'm using a pivot table on the project I'm working with to get works of users.

E.g: User::find(1)->works gives me the works of user with ID of 1.

The thing is that I want to filter this results with extra Pivot data.

Something like:

User::find(1)->works->pivot->where('active',1)->get();

In which the active is…

Top comments (0)