Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

colinlongworth's avatar

Is there a best practise for custom / preset queries?

I have a project where there are Students, and each student has multiple Enrollments. I want to allow an Instructor to create a report template, e.g. 'Show all students who completed Course A, B and C in the last 30 days' and save it so they can run the report anytime.

Is there a best practice for approaching this? A 'hacky' solution I thought of, given I'm using Livewire, would be to use the query string option, save the query string/filter values and redirect the URL so the filter is automatically applied. The issue, however, is that it only works for Livewire, so if I wanted to export the same report to a PDF, CSV, etc., then I'd need to convert it appropriately.

Another option would be to save the query as an array of values e.g.

[
    ['course_id', 'in', [123. 456, 789]],
    ['completed_at', 'gte', '30 days ago']
]
0 likes
0 replies

Please or to participate in this conversation.