DEV Community

Md Abdullah al noor
Md Abdullah al noor

Posted on

1

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay