Skip to content

Maintenance – Added order by in search function#130

Open
derpixler wants to merge 3 commits into
masterfrom
fixes/rr/43/added-order_by-in-search-function
Open

Maintenance – Added order by in search function#130
derpixler wants to merge 3 commits into
masterfrom
fixes/rr/43/added-order_by-in-search-function

Conversation

@derpixler

Copy link
Copy Markdown
Contributor

#Added sort_by and order_by parameters to search()

Based on #43 by @mostafaqanbaryan — thanks for the initial contribution!

References

What it does

Adds sort_by and order_by as optional parameters to Resource\AbstractResource::search(), allowing search results to be sorted server-side via the Zammad REST API:

$tickets = $client->resource(ResourceType::TICKET)->search(
    'my query',
    null,           // page (auto-paginate)
    null,           // per_page
    'created_at',   // sort_by
    'desc'          // order_by
);

Changes

  • search() and searchWithoutPagination() both accept $sort_by and $order_by as optional parameters (backwards compatible)
  • $order_by validated — must be "asc" or "desc", throws \RuntimeException otherwise
  • Tag::search() signature updated for parent class compatibility
  • Full PHPDoc coverage for all new parameters

Thanks

@mostafaqanbaryan for the original PR #43

@derpixler derpixler self-assigned this Jun 9, 2026
@derpixler derpixler changed the title Fixes/rr/43/added order by in search function Maintenance – Added order by in search function Jun 9, 2026
@derpixler derpixler requested a review from mgruner June 9, 2026 07:44

@mgruner mgruner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have some test coverage here, please?

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