Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In Laravel, we can apply multiple criteria filters using the where method on a database query builder. The where method can be used multiple times with different filter conditions to specify multiple criteria.

For example, let's say we have a users table and we want to filter users by their age and gender. We can use the following code:

$users = DB::table('users')
            ->where('age', '>', 30)
            ->where('gender', 'male')
            ->get();

This code will retrieve all users who are male and over 30 years of age.

We can also use the orWhere method to specify multiple criteria using OR conditions instead of AND conditions. For example:

$users = DB::table('users')
            ->where('age', '>', 30)
            ->orWhere('gender', 'male')
            ->get();

This code will retrieve all users who are either male or over 30 years of age.