Scorzio's avatar

Images don't save using Faker Image in seeder

I'm doing a project on Laravel 7 with FakerPHP, I want to populate my database with some random images and at the same time saving them on my local storage folder, but they can't get stored in the folder and I don't know why.

Here's my seeder:

for ($i=0; $i<20; $i++) {
            $newApartment = new Apartment();
            $newApartment->image = $faker->image('public/storage/images',300, 300);
            $newApartment->save();
        };

I want them to get stored on /images, but when I run the seeder no images is saved and when I check on my database all that appears is 0 on the image column. The storage works fine, I have no problems when uploading images directly from the site. I really don't know what I'm missing here, given that not a single error occurs and the seeding proceeds just fine.

0 likes
3 replies
aurelianspodarec's avatar
Level 7

Sadly the url the $faker->image is using is down, so it won't work - the URL that's using is http://lorempixel.com

You can always import fake images to your storage and then randomly apply them - that's what I do.

Scorzio's avatar

@aurelianspodarec Thanks for the reply! On the docs it says that it's using placeholder dot com, I don't even know at this point, I guess I'll do as you suggested, it may be the fastest solution

aurelianspodarec's avatar

@Scorzio I suppose that's the same thing? Maybe. It doesn't work either if you visit that site you mentioned.

faker image seems to be just broken because the URL where the images are getting from doesn't work.

Please or to participate in this conversation.