make()->each(function (Testimonial $testimonial, int $key) { $testimonial->picture = FileStorageHelper::storeFile( $testimonial, new \SplFileInfo(\resource_path( '../database/factories/assets/testimonials/default-picture-550x315.png' )) ); $testimonial->order = $key + 1; $testimonial->saveQuietly(); }); Testimonial::query()->inRandomOrder()->limit(rand(1, 5))->update(['published' => true]); } }