Skip to content

[9.x] Added callback support on implode Collection method.#41405

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
eusonlito:patch-3
Mar 9, 2022
Merged

[9.x] Added callback support on implode Collection method.#41405
taylorotwell merged 2 commits into
laravel:9.xfrom
eusonlito:patch-3

Conversation

@eusonlito
Copy link
Copy Markdown
Contributor

Allow to use a callback as $value on implode Collection method to simplify ->map()->implode() calls:

Before:

<span>{{ $user->cities->map(fn ($city) => $city->name.' ('.$city->state->name.')')->implode(', ') }}</span>

After:

<span>{{ $user->cities->implode(fn ($city) => $city->name.' ('.$city->state->name.')', ', ') }}</span>

Allow to use a callback as `$value` on `implode` Collection method to simplify -`>map()->implode()` calls:

Before:

```php
<span>{{ $user->cities->map(fn ($city) => $city->name.' ('.$city->state->name.')')->implode(', ') }}</span>
```

After:

```php
<span>{{ $user->cities->implode(fn ($city) => $city->name.' ('.$city->state->name.')', ', ') }}</span>
```
@driesvints
Copy link
Copy Markdown
Member

@eusonlito this broke something: #41466

@eusonlito
Copy link
Copy Markdown
Contributor Author

Ok is_callable must be replaced with $this->useAsCallable.

@eusonlito
Copy link
Copy Markdown
Contributor Author

eusonlito commented Mar 14, 2022

@driesvints fixed with PR #41468 Sorry.

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

Successfully merging this pull request may close these issues.

3 participants