You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Laravel Orion's search endpoint is a powerful feature that could be even more versatile. Currently, for example, when users search for documents, they can apply various filters and receive results through this endpoint.
Feature request
I propose extending the functionality of the search endpoint to allow for alternative output formats while utilizing the same search parameters and accessing the underlying QueryBuilder. This enhancement would enable features like:
Downloading search results as an Excel file
Returning aggregated data (e.g., SQL gropy by) in JSON format to populate charts
Dispatching jobs to delay heavy load processing
Current Workaround
For the past two years, I've implemented a solution across several projects to achieve this functionality. However, this approach feels cumbersome and could be vulnerable to breaking changes. My current method involves:
Extending the base Controller, e.g.: RelationController
Referencing the search method in a new route
Overriding the beforeIndex() method to return custom output
Example using the Laravel Excel package to generate spreadsheets from a RelationController:
This approach offers flexibility, particularly for scenarios involving heavy data processing where a Job might need to be dispatched to run the query later. While the QueryBuilder can't be natively serialized in Laravel, the filters array can be easily serialized when dispatching a Job. Defining custom methods allows full use of Laravel Controllers' features, such as dependency injection, enhancing flexibility and adherence to Laravel's design principles.
This discussion was converted from issue #266 on September 16, 2024 11:11.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Current feature
Laravel Orion's search endpoint is a powerful feature that could be even more versatile. Currently, for example, when users search for documents, they can apply various filters and receive results through this endpoint.
Feature request
I propose extending the functionality of the
search
endpoint to allow for alternative output formats while utilizing the same search parameters and accessing the underlyingQueryBuilder
. This enhancement would enable features like:Current Workaround
For the past two years, I've implemented a solution across several projects to achieve this functionality. However, this approach feels cumbersome and could be vulnerable to breaking changes. My current method involves:
RelationController
search
method in a new routebeforeIndex()
method to return custom outputExample using the Laravel Excel package to generate spreadsheets from a RelationController:
Proposed Solution
I suggest implementing this feature in two steps:
This approach offers flexibility, particularly for scenarios involving heavy data processing where a Job might need to be dispatched to run the query later. While the
QueryBuilder
can't be natively serialized in Laravel, the filters array can be easily serialized when dispatching a Job. Defining custom methods allows full use of Laravel Controllers' features, such as dependency injection, enhancing flexibility and adherence to Laravel's design principles.Proposed implementation:
Downloading a spreadsheet:
or dispatching a Job:
This enhancement would significantly improve the flexibility and maintainability of the search functionality while preserving its core strengths.
Beta Was this translation helpful? Give feedback.
All reactions