getTypes(); for ($i = 0; $i < 50; $i++) { $typeIndex = array_rand( $types ); $items = $types[$typeIndex]->getItems(); $type = $items[array_rand( $items )]; $parentId = $faker->randomElement([null, $chartOfAccountRepositoryInterface->getRandomId(true)]); $chartOfAccountRepositoryInterface->create( (new ChartOfAccountAttr) ->setChartOfAccountId($parentId) ->setName($faker->unique()->colorName()) ->setType($type) ->setCode($faker->currencyCode) ->setDescription($faker->text()) ); } } }