getTable())->truncate(); Schema::enableForeignKeyConstraints(); File::deleteDirectory(\storage_path('app/public/modelfiles/' . (new Product())->getTable())); Range::all()->each( fn (Range $range) => Product::factory(\random_int(6, 10))->make()->each(function (Product $product) use ($range) { $product->picture = FileStorageHelper::storeFile( new Product(), new \SplFileInfo( \resource_path('../database/factories/assets/products/default-picture-800x800.jpg') ) ); $product->range()->associate($range); $product->save(); }) ); } }