make() ->each(function ($model) { $content = $model->content; // Config factories add just one depth of children. foreach ($model->content as $key => $value) { $prefix = sprintf("%s_", DynamicFieldTypes::image->name); if (Str::startsWith($key, $prefix)) { $content[$key] = FileHelper::storeFile( $model, new \SplFileInfo(\resource_path( '../database/factories/assets/dynamic-pages/100x100.jpg' )) ); } } $model->content = $content; $model->saveOrFail(); }); } }