/** * @param TestEntity $model */ protected function addRelatedEntities(TestEntity $model) { $this->getFactory(SecondTestEntity::class)->count(5)->make()->each(function (SecondTestEntity $entity) use($model) { $model->testMany()->save($entity); }); }