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