Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cms] $pages->intersection() / $pages->intersect() #214

Closed
neildaniels opened this issue Mar 6, 2019 · 2 comments

Comments

@neildaniels
Copy link

@neildaniels neildaniels commented Mar 6, 2019

It would be very handy to have a Pages/Collection method that takes in another Pages/Collection object and returns the intersection.

I would expect a version that merely returns the intersection to be called ->intersection(). If it was a mutable method, I would expect it to be called ->intersect(). I would prefer the first version that didn't actually mangle with any collections.

My current alternative is simply the following, but I don't think it's obvious.

$intersection = $pagesA->find($pagesB->pluck('id'));

Proposed:

$intersection = $pagesA->intersection($pagesB);
@distantnative distantnative changed the title $pages->intersection() / $pages->intersect() [Cms] $pages->intersection() / $pages->intersect() Mar 7, 2019
@texnixe

This comment has been minimized.

Copy link

@texnixe texnixe commented Mar 12, 2019

Instead of using pluck() you can also search the keys, probably more obvious:

$pagesA->find($pagesB->keys());

You could create a custom method.

@bastianallgeier

This comment has been minimized.

Copy link
Contributor

@bastianallgeier bastianallgeier commented Oct 15, 2019

Roadmap automation moved this from Backlog to Done Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Roadmap
  
Done
4 participants
You can’t perform that action at this time.