8000 [5.x] Allow passing computed fields via an associative array by godismyjudge95 · Pull Request #11528 · statamic/cms · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[5.x] Allow passing computed fields via an associative array #11528

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

Merged
merged 9 commits into from
Mar 17, 2025

Conversation

godismyjudge95
Copy link
Contributor

We have a number of computed properties for a specific collection and our AppServiceProvider is getting rather long with all the computed properties.

This PR helps solve this by allowing for an associative array to be passed as the 2nd parameter:

Collection::computed('properties', [
  'pdf_url' => fn ($entry, $value) => route('properties.pdf', $entry->id()),
  'deletion_date' => fn ($entry, $value) => $this->generateDeletionDate($entry),
]);

Let me know if you'd like me to add tests

@godismyjudge95 godismyjudge95 changed the title [5x] Allow passing computed fields via an associative array [5.x] Allow passing computed fields via an associative array Mar 4, 2025
@duncanmcclean
Copy link
Member

Let me know if you'd like me to add tests

If you can, that would be great!

We have existing tests for computed values in UserContractTests and EntryTest.

@jasonvarga jasonvarga merged commit 38a6099 into statamic:5.x Mar 17, 2025
24 checks passed
@godismyjudge95 godismyjudge95 deleted the patch-1 branch March 17, 2025 20:32
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
0