Skip to content

[12.x] Allow passing an enum to Builder::orderBy() #56250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Jul 9, 2025

At work, we have three or four separate projects, each which has a SortDirection enum. We use the enum to validate against in HTTP requests, but always have to remember to add ->value when sorting, eg) Athlete::query()->orderBy('last_name', $request->sort->direction->value).

I believe it is a mathematical impossibility that we are the only folks who have this issue. This is certainly not broken as-is, just adding a small quality of life improvement for improved DX.

@cosmastech cosmastech marked this pull request as draft July 9, 2025 11:27
@shaedrich
Copy link
Contributor

shaedrich commented Jul 9, 2025

I wonder if Laravel should provide said hypothetical enum rather than letting every implementation provide their own since the available options are quite clear.

@cosmastech cosmastech marked this pull request as ready for review July 10, 2025 01:58
@taylorotwell
Copy link
Member

I feel like if we keep going down this path every method in the framework that accepts a string will have to accept an enum. 🙃

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