diff --git a/database/factories/AccessoryFactory.php b/database/factories/AccessoryFactory.php index 352f0b1540..9e69004862 100644 --- a/database/factories/AccessoryFactory.php +++ b/database/factories/AccessoryFactory.php @@ -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, diff --git a/database/seeds/AccessorySeeder.php b/database/seeds/AccessorySeeder.php index 9cb9e0aff6..a9041b782c 100644 --- a/database/seeds/AccessorySeeder.php +++ b/database/seeds/AccessorySeeder.php @@ -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); + } + } } } diff --git a/public/img/demo/accessories/bluetooth.jpg b/public/img/demo/accessories/bluetooth.jpg new file mode 100644 index 0000000000..0d3558c4dc Binary files /dev/null and b/public/img/demo/accessories/bluetooth.jpg differ diff --git a/public/img/demo/accessories/comfort-mouse.jpg b/public/img/demo/accessories/comfort-mouse.jpg new file mode 100644 index 0000000000..6652da1189 Binary files /dev/null and b/public/img/demo/accessories/comfort-mouse.jpg differ diff --git a/public/img/demo/accessories/magic-mouse.jpg b/public/img/demo/accessories/magic-mouse.jpg new file mode 100644 index 0000000000..b23683fb4b Binary files /dev/null and b/public/img/demo/accessories/magic-mouse.jpg differ diff --git a/public/img/demo/accessories/usb-keyboard.jpg b/public/img/demo/accessories/usb-keyboard.jpg new file mode 100644 index 0000000000..e87fa202a5 Binary files /dev/null and b/public/img/demo/accessories/usb-keyboard.jpg differ