1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00
laravel-tips/content/tips/use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request.md
2022-01-07 13:58:01 +01:00

717 B
Raw Blame History

title tweet_id thread_slug author_username images created_at slug
Use match () or switch () statements to conditionally scope database queries based on query strings in the request 1471864655710670854 weekly-thread-2021-01 archtechx
https://pbs.twimg.com/media/FGmQH5nXEAs4mnv.jpg
2021-12-17T15:27:34+00:00 use-match-or-switch-statements-to-conditionally-scope-database-queries-based-on-query-strings-in-the-request

Remembered this great tip recently, and it's nice to see how fast PHP evolves

The exact same behavior can be implemented using match () with a default value, which also removes the need for the second callback https://twitter.com/reinink/status/1233017064492761088