Trying to get all contacts cases using bean factory

Hi am trying to amend some old code that uses beanFactory. We have an API endpoint that gets a contact and there account as well as some other information. I need to amed this so it get all the contacts cases.

I added in a relationship 

            if ($contactBean->load_relationship('cases')) {
                $caseBeans = $contactBean->cases->getBeans();
                $parentBean = false;
                if (!empty($caseBeans)) {
                    reset($caseBeans);
                    foreach($caseBeans as $case) {
                        $result['cases'][] = $helper->formatForApi($case, array(
                            'id', 
                            'name',
                        ));
                    }
                }
            };

this returns only the first case and not an array of them all

    "cases": [
        {
            "id": "23a65880-4628-11ed-8f5d-023af1fa0476",
            "name": "CASE-81964",
            "_acl": {
                "fields": {}
            }
        }
    ],

Im not that familiar with bean-factory and am wondering if this would be better written as a custom SQL query, In addition can you get the total number of cases for a contact using bean-factory like a count()