// image 100x100
$faker->imageUrl(100, 100);
random image
Is it possible to seed my database by random dummy image?
What kind of image would that be?
I wonder if this is the only reference for seeder:
https://laravel.com/docs/5.6/seeding
I wonder how to seed integer random data or only limited integer from 1 up to 3 for example. and what about image?
Why use $faker? In the reference they use:
DB::table('banks')->insert([
'bank_name' => str_random(10),
'bank_owner' => str_random(10),
'bank_pin' => str_random(10),
'bank_status' => str_random(10),
]);
Should I put
'bank_pic' => $faker->imageUrl(100, 100),
for example?
@davy_yg this is fake data, so, faker is created exactly for this. Other alternatives are
'image' => 'https://placeimg.com/100/100/any?' . rand(1, 100),
or
'image' => 'http://via.placeholder.com/100x100'
To seed integer random data or limited integers, it depends on the situation.
let say the column name is bank_pic and the location - localhost/eliteshop/images :
'bank_pic' => 'localhost/eliteshop/images'
Will this code create images? How do they know the image size?
If I use this code
'bank_pic' => $faker->imageUrl(100, 100),
How do they know the location of the image file? and will the images will actually be created?
Fetch the files in the folder, choose a random file.
@davy_yg you don't need to store real images in localhost/eliteshop/images
$faker->imageUrl(100,100)
will generate an url for the images.
How do they know the location of the image file?
// this variable is going to have a random image url from fake sites
// something like this: https://lorempixel.com/100/100/?39966
$bank->bank_pic
and will the images will actually be created?
No, you have full url which references on remote servers for images.
If you need to actually generate an image instead of external links, http://php.net/manual/en/function.imagecreate.php
@SERGIU17 - Thank you
Please or to participate in this conversation.