Error at convert string to integer

Good morning, I was developing the backend of my web application and I found this error and I don’t know how to solve it. The error is “Cannot convert value of type string to integer”. This is the code where I get this error.

    private function getStatusCustomerSimcards()
    {
        // Cargar el modelo de la vista
        $vStatusCustomerSimcards = TableRegistry::get('VStatusCustomerSimcards');
        // Construir la subconsulta
        $subquery = $vStatusCustomerSimcards->find();
        $subquery->select([
            'id_customer' => 'customer_orders.id_customer',
            'status_name' => 'simcard_statuses.name',
            'total_sims' => $subquery->func()->count('simcards.iccid')
        ])
            ->join([
                'simcards' => [
                    'table' => 'simcards',
                    'type' => 'INNER',
                    'conditions' => 'customer_orders.id_order = simcards.id_customer_order'
                ],
                'simcard_statuses' => [
                    'table' => 'simcard_statuses',
                    'type' => 'INNER',
                    'conditions' => 'simcards.id_simcard_status = simcard_statuses.id_simcard_status'
                ]
            ])
            ->group(['customer_orders.id_customer', 'simcard_statuses.name']);
        // Construir la consulta principal
        $query = $vStatusCustomerSimcards->find();

        $query->select([
            'id_customer',
            'total_inactive_sims' => $query->func()->sum(
                $query->newExpr()->addCase(
                    [$query->newExpr()->eq('co.status_name', 'Inactive')],
                    ['co.total_sims'],
                    ['integer']

                )
            ),
            'total_test_sims' => $query->func()->sum(
                $query->newExpr()->addCase(
                    [$query->newExpr()->eq('co.status_name', 'Test')],
                    ['co.total_sims'],
                    ['integer']


                )
            ),
            'total_activation_ready_sims' => $query->func()->sum(
                $query->newExpr()->addCase(
                    [$query->newExpr()->eq('co.status_name', 'Activation Ready')],
                    ['co.total_sims'],
                    ['integer']



                )
            ),
            'total_active_sims' => $query->func()->sum(
                $query->newExpr()->addCase(
                    [$query->newExpr()->eq('co.status_name', 'Active')],
                    ['co.total_sims'],
                    ['integer']


                )
            ),
            'total_suspended_sims' => $query->func()->sum(
                $query->newExpr()->addCase(
                    [$query->newExpr()->eq('co.status_name', 'Suspended')],
                    ['co.total_sims'],
                    ['integer']


                )
            ),
            'total_deactivated_sims' => $query->func()->sum(
                $query->newExpr()->addCase(
                    [$query->newExpr()->eq('co.status_name', 'Deactivated')],
                    ['co.total_sims'],
                    ['integer']


                )
            ),
            'total_cooldown_sims' => $query->func()->sum(
                $query->newExpr()->addCase(
                    [$query->newExpr()->eq('co.status_name', 'Cooldown')],
                    ['co.total_sims'],
                    ['integer']


                )
            ),
        ])
            ->from(['co' => $subquery])
            ->group(['id_customer']);

        try {
            $results = $query->all(); // Ejecutar la consulta y obtener los resultados
            return $results; // Devolver los resultados
        } catch (Exception $error) {
            // Manejar la excepción
            $this->Flash->error(__('Error al obtener el estado de las SIMs de los clientes: ' . $error->getMessage()));
            return [];
        }
    }

A stacktrace would be nice.

But the error message Cannot convert value of type string to integer indicates you have data inside your table/column you are selecting which you are expecting to be an integer but it actually isn’t.

So maybe try to enable SQL Logging or try debug($query->sql()) and execute that SQL directly inside a SQL CLI, PHPMyAdmin or wherever you like to execute sql.