TheBAST
TheBAST

Reputation: 2736

Laravel Query Multiple Conditions

 public function queryCountUsers($query) {
        $query->where(['confirmed' => true])->count();
    }

I want to query all the users who are already confirmed and those all users who have role_id of 2 or 3 but How can i do it ?

Upvotes: 2

Views: 80

Answers (1)

Daniel
Daniel

Reputation: 11192

You could add ->where('role_id',2)->orWhere('role_id',3) to your function, but it's probably a better idea to use Laravel's whereIn function:

$query->where(['confirmed' => true])->whereIn('role_id', [2,3])->count();

This is supported in every version of Laravel.

Upvotes: 1

Related Questions