← All tasks
🧮
Programming Intermediate

Write a Conditional Query With when()

⏱ 3 min ⭐ 90 XP 🔁 3 attempts allowed

What you'll do

Write the Eloquent expression that filters posts by category only when a $category variable is not null.

Scenario

A search endpoint should apply the category filter only if the user actually selected one.

Ready to try it?

Create a free account and try "Write a Conditional Query With when()" free for 7 days, no card required. Earn 90 XP and track your internship progress.

Already have an account? Sign in