10 months ago

Fluent pivot scope

Posted 10 months ago by fabricecw


I try to keep my models as clean as possible. But when it comes to pivot scopes, I'm unsure what the cleanest approach could be.

I need to filter through a pivot column completed_at:

$this->statuses()->wherePivot('completed_at', null)->get();

But it would be much more readable this way:


What's the best way to do make it this fluent? And should it be done this way?

Many thanks and regards,

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