👩💻 Join our community of thousands of amazing developers!
If you have been working with Laravel lately, you might have used this feature called “conditional clauses” using which you will be able to run a certain callback when a condition becomes true. For instance, take the example of Laravel’s query builder where using the when method, you can query clauses to apply to a query based on another condition like so. $isAdmin = $request->input('is_admin'); $books = DB::table('books') ->when($isAdmin, function ($query, $role) { ...