where(function ($query) use ($data) { if (!empty($data['cpf'])) { $query->orWhere( 'cpf', $data['cpf'] ); } if (!empty($data['registration'])) { $query->orWhere( 'registration', $data['registration'] ); } if (!empty($data['name'])) { $query->orWhere( 'name', 'like', '%' . $data['name'] . '%' ); } }) ->first(); } }