Added accessories images for seeder

This commit is contained in:
snipe 2018-09-29 22:17:14 -07:00
parent 79367642b1
commit a481fa2921
6 changed files with 30 additions and 0 deletions

View file

@ -21,6 +21,7 @@ $factory->state(App\Models\Accessory::class, 'apple-bt-keyboard', function ($fak
return [
'name' => 'Bluetooth Keyboard',
'image' => 'bluetooth.jpg',
'category_id' => 8,
'manufacturer_id' => 1,
'qty' => 10,
@ -34,6 +35,7 @@ $factory->state(App\Models\Accessory::class, 'apple-usb-keyboard', function ($fa
return [
'name' => 'USB Keyboard',
'image' => 'usb-keyboard.jpg',
'category_id' => 8,
'manufacturer_id' => 1,
'qty' => 15,
@ -47,6 +49,7 @@ $factory->state(App\Models\Accessory::class, 'apple-mouse', function ($faker) {
return [
'name' => 'Magic Mouse',
'image' => 'magic-mouse.jpg',
'category_id' => 9,
'manufacturer_id' => 1,
'qty' => 13,
@ -60,6 +63,7 @@ $factory->state(App\Models\Accessory::class, 'microsoft-mouse', function ($faker
return [
'name' => 'Sculpt Comfort Mouse',
'image' => 'comfort-mouse.jpg',
'category_id' => 9,
'manufacturer_id' => 2,
'qty' => 13,

View file

@ -13,5 +13,31 @@ class AccessorySeeder extends Seeder
factory(Accessory::class, 1)->states('apple-bt-keyboard')->create();
factory(Accessory::class, 1)->states('apple-mouse')->create();
factory(Accessory::class, 1)->states('microsoft-mouse')->create();
$src = public_path('/img/demo/accessories/');
$dst = 'accessories'.'/';
$del_files = Storage::files($dst);
foreach($del_files as $del_file){ // iterate files
$file_to_delete = str_replace($src,'',$del_file);
\Log::debug('Deleting: '.$file_to_delete);
try {
Storage::disk('public')->delete($dst.$del_file);
} catch (\Exception $e) {
\Log::debug($e);
}
}
$add_files = glob($src."/*.*");
foreach($add_files as $add_file){
$file_to_copy = str_replace($src,'',$add_file);
\Log::debug('Copying: '.$file_to_copy);
try {
Storage::disk('public')->put($dst.$file_to_copy, file_get_contents($src.$file_to_copy));
} catch (\Exception $e) {
\Log::debug($e);
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB