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

Imposible to use find #184

Open
mgralikowski opened this issue Feb 9, 2022 · 2 comments
Open

Imposible to use find #184

mgralikowski opened this issue Feb 9, 2022 · 2 comments

Comments

@mgralikowski
Copy link

When we try to find a country by alternative names using sth like this:

(new Countries())->first(fn ($item): bool => \in_array($country, $item->alt_spellings, true))

We always get an error:

Exception : Serialization of 'Closure' is not allowed

It doesn't matter we use first() or filter(). Any option to use a function is not possible.

@mgralikowski
Copy link
Author

Ok, found a workaround.

Countries::all()->first(fn (Collection $item): bool => $item->alt_spellings->contains($country))

So we first take all countries and then filter.

@xtrcode
Copy link

xtrcode commented Apr 3, 2022

Ok, found a workaround.

Could you please close the issue?

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

No branches or pull requests

2 participants