---
title: "Discussion on \"Stop wrapping your queries in if-statements\" | Hashnode"
description: "Discussion on \"Stop wrapping your queries in if-statements\". You've written this. A couple of optional filters, so you do the little dance:\n$query = User::query();\n\nif ($request->status) {\n    $query->where('status', $request->status);\n}\nif ($request->search) {"
url: "https://hashnode.com/posts/stop-wrapping-your-queries-in-if-statements/6a7604c02b8484376f7505b7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Stop wrapping your queries in if-statements](https://nodenuggets.hashnode.dev/stop-wrapping-your-queries-in-if-statements?utm_source=hashnode&utm_medium=feed)

You've written this. A couple of optional filters, so you do the little dance: $query = User::query(); if ($request->status) { $query->where('status', $request->status); } if ($request->search) {

Aug 7 · 1 min read · nodenuggets.hashnode.dev  
Read the article

## Written by

[Catherine Kimani](https://hashnode.com/@CodeWithCatherine)

@CodeWithCatherine · Kenya,Nairobi

  
[View profile](https://hashnode.com/@CodeWithCatherine)

Building and Learning, One Line of Code at a Time

Developer with a passion for coding. I enjoy creating impactful applications and exploring new technologies. Let's embark on this coding adventure together, building innovative solutions along the way

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
