[6.x] Added three new lifecylce hooks (transform query, actions and rows)#2095
Open
johannesMEGABAD wants to merge 5 commits intoPower-Components:6.xfrom
Open
[6.x] Added three new lifecylce hooks (transform query, actions and rows)#2095johannesMEGABAD wants to merge 5 commits intoPower-Components:6.xfrom
johannesMEGABAD wants to merge 5 commits intoPower-Components:6.xfrom
Conversation
MrYamous
reviewed
Apr 1, 2026
Contributor
MrYamous
left a comment
There was a problem hiding this comment.
I feel like this PR includes more files than expected, are these the right branches ?
Contributor
Author
Hey! Yeah the files are from running pint. I forked the 6.x branch and had tests fail due to styling. Then I ran pint for formatting and it linted like a lot of files. |
MrYamous
reviewed
Apr 2, 2026
Member
|
Hello @johannesMEGABAD, Thank you for this. Can you update with the last commit in the v6 branch? |
Contributor
Hey! Yes I will do on tuesday when I am back |
Contributor
Author
Hey :) I merged in the latest commits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⚡ PowerGrid - Pull Request
Description
This PR introduces three new lifecycle hooks that allow users to modify dataat key stages of the PowerGrid pipeline.
New Hooks
All hooks are defined in the
Hookstrait (src/Concerns/Hooks.php) with no-op defaults, making them fully opt-in.transformQuery(mixed $query): mixedModify the query after filters, search, and sorting are applied but before pagination executes it. Useful for eager loading, subqueries,
withCount(), or any query-level adjustments that depend on the current filter state.Applies to
ModelProcessorandScoutBuilderProcessor.transformRows(Collection $rows): CollectionModify the paginated rows after the query has executed and data has been transformed, but before it is passed to the view. Runs on the current page's rows only. Ideal for enriching rows with data from external APIs or computed values not available at query time.
transformActions(array $actionsByRow, Collection $rows): arrayModify the resolved actions array before it is dispatched to the frontend via JS. Receives both the
$actionsByRowdictionary (keyed by primary key) and the current$rowscollection. Useful for dynamically changing button labels, visibility, or attributes based on data not available duringactions()resolution.Each action in the array has these modifiable keys:
action,can,slot,tag,icon,iconAttributes,attributes,rules.Pipeline Position
Files Changed
src/Concerns/Hooks.php- AddedtransformQuery,transformRows, andtransformActionshook definitionssrc/PowerGridComponent.php- IntegratedtransformRowsandtransformActionsintogetRecordsFromCache()andgetRecordsDataSource(); addedapplyAfterQuery()helpersrc/DataSource/Processors/ModelProcessor.php- IntegratedtransformQuerybetween filter/sort pipeline and paginationsrc/DataSource/Processors/ScoutBuilderProcessor.php- SametransformQueryintegrationTests
tests/Concerns/Components/DishesTransformHooksTable.php- Test component with toggleable flags for each hooktests/Feature/TransformHooksTest.php- 12 test cases (4 scenarios x 3 themes: Tailwind, Bootstrap, DaisyUI)transformRows modifies row data before renderingtransformQuery filters the query before paginationtransformActions modifies action attributes before renderingtransformRows and transformQuery can be combinedRelated Issue(s):
Documentation
This PR requires Documentation update?