How to use when() method in Laravel Eloquent Queries or Collection
Introduction
In this article i’ll show you how to use when() method in a Laravel application as an alternative to the typical/traditional conditional (if-else) statements/blocks in PHP.
Typical if-else use case
$query = Post::query();
...
alemsbaja.hashnode.dev4 min read