PetroGromovo's avatar

How to add add dummy images with fzaninotto/Faker ?

Looking how https://github.com/fzaninotto/Faker works I search a way to add dummy images and I see

Faker\Provider\Imag
// Image generation provided by LoremPixel (http://lorempixel.com/)

I wonder if there is a way to upload these images and save it under storage using spatie/laravel-medialibrary ?

If yes, please example.

Thanks!

0 likes
2 replies
aschmelyun's avatar
Level 4

@petrogromovo You sure can! You can do something like this:

// don't have to include this if you're in a factory class
$faker = \Faker\Factory::create();

$user = User::find(1);
$user->addMedia($faker->image())->toMediaCollection('avatars');
1 like

Please or to participate in this conversation.