I am having trouble storing images in the 'public' folder of the Laravel framework (which I believe is the static content folder? Please correct me if I am wrong).
I am running a seed using faker which generates images and stores the images URL's in a table. This is all working correctly but the seed itself keeps failing as it can't seem to access or find the folder within the public folder I have created. This is my public folder structure:
/public/assets/images
And here is my seed which should save my images into this folder:
<?php
use Illuminate\Database\Seeder;
class ProductsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('products')->truncate();
$faker = Faker\Factory::create();
$limit = 30;
for($i = 0; $i < $limit; $i++) {
DB::table('products')->insert([
'title' => $faker->name,
'SKU' => $faker->name,
'description' => $faker->text,
'created_at' => $faker->dateTime,
'updated_at' => $faker->dateTime,
'images' => $faker->image(URL::to(Config::get('assets.images')) ,800, 600, [], [])
]);
}
}
}#
The 'assets.images' config file is:
<?php
return [
'images' => '/assets/images'
];
When I try and run the seed to populate my database I get the following error:
[InvalidArgumentException]
Cannot write to directory "http://localhost:8931/assets/images"
I cannot see where I am going wrong. Can anyone offer any insight?