0
votes

I currently have in CakePHP 3 a table called Tickets that has a few flags such as head_ticket and latest_ticket. Essentially when ever I edit a record I create a new row (a uuid field keeps the records linked together) and set the latest_ticket flag to true as this row contains the latest information.

What I would like to know is that is there a way I can do something in the find where I can get all the records that have the head_ticket set to true but update the head ticket data columns returned on-the-fly with the latest data from the row that has the latest_ticket flag set to true at the same time? It's almost like an afterFind scenario but one which has been deprecated in CakePHP 3

Thanks

1

1 Answers

1
votes

Read the migration guide, it contains the answer to your question and probably more things you want and should to know when coming from 2.x:

Using the Modifying Results with Map/Reduce features of the ORM allow you to build aggregated data from your results, which is another use case that the afterFind callback was often used for.

The documentation about Map/Reduce contains an example for result set aggregation based on some filter, I think this is pretty much what you want.