[Request] Refactor/inspection for orderBy
Description
When using a query builder, it could be cool with suggestions for how to write it smarter.
So utilising the helper methods for writing orderBy clauses shorter.
Examples
For example, having the following code
$query->orderBy('read_at', 'desc')
Can be rewritten to the following scenarios
$query->orderByDesc('read_at')
$query->latest('read_at')
And this
$query->orderBy('created_at', 'asc')
Can be rewritten to the two following scenarios
$query->orderBy('created_at')
$query->oldest()
Problems
When to suggest orderBy over latest/oldest
Either always show both scenarios when refactor and if one of them is chosen then the inspection is fine with it.
Or look at the field, so if it is a date field or ends with _at then use latest/oldest syntax over orderBy syntax.
Nice. I'll think about it. Thanks. BTW,
$query->orderBy('read_at', 'desc')
Do you have completion for 'read_at' and other fields there?
@adelf Yep! 👍
I think the problem of hints for the latest and oldest methods can be attributed to the current issue.



@andrey-helldar I complete only date fields for oldest/newest methods. Phpdoc for these methods: "Add an "order by" clause for a timestamp to the query."
However, I can add all fields there...
@adelf, I personally like to call oldesr and latest methods instead of orderBy. Therefore, I would prefer to be able to fill quickly 🙂
Whatever... it will complete all fields in the next version.