Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Introduce HigherOrderWhenProxy #1881

Closed
netpok opened this issue Oct 13, 2019 · 2 comments
Closed

Introduce HigherOrderWhenProxy #1881

netpok opened this issue Oct 13, 2019 · 2 comments

Comments

@netpok
Copy link

netpok commented Oct 13, 2019

I propose we introduce proxies for when on collections and the query builder.

Example use cases:

  • Collection sorting: $collection->when($field)->sortBy($field)
  • Database filtering: User::when($coreDataOnly)->select(['name', 'email'])->get()

Working principle:

  • if the value is true, then the called method is called on the target object and the result is returned
  • if the value is false, then the called method is skipped and the target is returned
@driesvints
Copy link
Member

Closing as this idea was rejected by Taylor.

@netpok
Copy link
Author

netpok commented Jun 10, 2021

This feature was implemented in 9.x via #37632

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants