Cannot convert value of type string to integer

I would need to update the number of pieces by bulk update. But I don’t know how to put the right variable there. Please, give me an advice.

    'stock' => 'stock' - $item->pcs,
], [
    'id' => $item->goods_item_id,

Column stock is integer

There’s various ways to do that. With dynamic values involved, personally I’d suggest to create the update query manually, so that you can safely bind the values:

$statement = $this->GoodsItems
    ->set(['stock = stock - :pcs'])
    ->bind(':pcs', $item->pcs, 'integer')
    ->where(['id' => $item->goods_item_id])

$affected = $statement->rowCount();