User::where('username','john doe') ->where(function($query) { $query->where('age','>',30) ->orWhere('email','=','johndoe@xyz.com'); }) ->toSql();