Please, can we add when()
method for conditional clause to make code more readable/concise.
https://laravel.com/docs/8.x/queries#conditional-clauses
I saw a code somewhere:
const query = User.page(params.page || 1) .include('avatar') .orderBy(params.sort) if (params.search) { query.where('search', params.search) } const result = await query.params({ limit: 20 }).get()
Would be re-written to:
const result = await User.page(params.page || 1) .include('avatar') .orderBy(params.sort) .when(params.search, (query, search) => query.where('search', search)) .params({ limit: 20 }) .get()
Peter-Krebs and JoaoPedroAS51
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4