diff --git a/app/Console/Commands/MoveUploadsToNewDisk.php b/app/Console/Commands/MoveUploadsToNewDisk.php index a6c93e1735..9bd3a94aba 100644 --- a/app/Console/Commands/MoveUploadsToNewDisk.php +++ b/app/Console/Commands/MoveUploadsToNewDisk.php @@ -47,33 +47,33 @@ class MoveUploadsToNewDisk extends Command } $delete_local = $this->argument('delete_local'); - $public_uploads['accessories'] = glob('storage/app/public/accessories'."/*.*"); - $public_uploads['assets'] = glob('storage/app/public/assets'."/*.*"); - $public_uploads['avatars'] = glob('storage/app/public/avatars'."/*.*"); - $public_uploads['categories'] = glob('storage/app/public/categories'."/*.*"); - $public_uploads['companies'] = glob('storage/app/public/companies'."/*.*"); - $public_uploads['components'] = glob('storage/app/public/components'."/*.*"); - $public_uploads['consumables'] = glob('storage/app/public/consumables'."/*.*"); - $public_uploads['departments'] = glob('storage/app/public/departments'."/*.*"); - $public_uploads['locations'] = glob('storage/app/public/locations'."/*.*"); - $public_uploads['manufacturers'] = glob('storage/app/public/manufacturers'."/*.*"); - $public_uploads['suppliers'] = glob('storage/app/public/suppliers'."/*.*"); - $public_uploads['assetmodels'] = glob('storage/app/public/models'."/*.*"); + $public_uploads['accessories'] = glob('public/accessories'."/*.*"); + $public_uploads['assets'] = glob('public/assets'."/*.*"); + $public_uploads['avatars'] = glob('public/avatars'."/*.*"); + $public_uploads['categories'] = glob('public/categories'."/*.*"); + $public_uploads['companies'] = glob('public/companies'."/*.*"); + $public_uploads['components'] = glob('public/components'."/*.*"); + $public_uploads['consumables'] = glob('public/consumables'."/*.*"); + $public_uploads['departments'] = glob('public/departments'."/*.*"); + $public_uploads['locations'] = glob('public/locations'."/*.*"); + $public_uploads['manufacturers'] = glob('public/manufacturers'."/*.*"); + $public_uploads['suppliers'] = glob('public/suppliers'."/*.*"); + $public_uploads['assetmodels'] = glob('public/models'."/*.*"); // iterate files foreach($public_uploads as $public_type => $public_upload) { $type_count = 0; - $this->info("\nThere are ".count($public_upload).' PUBLIC '.$public_type.' files.'); + $this->info("- There are ".count($public_upload).' PUBLIC '.$public_type.' files.'); for ($i = 0; $i < count($public_upload); $i++) { $type_count++; $filename = basename($public_upload[$i]); try { - Storage::disk('public')->put($public_type.'/'.$filename, file_get_contents($public_upload[$i])); - $new_url = Storage::disk('public')->url($public_type.'/'.$filename, $filename); + Storage::disk('public')->put('uploads/'.public_type.'/'.$filename, file_get_contents($public_upload[$i])); + $new_url = Storage::disk('public')->url('uploads/'.$public_type.'/'.$filename, $filename); $this->info($type_count.'. PUBLIC: '.$filename.' was copied to '.$new_url); } catch (\Exception $e) { \Log::debug($e); @@ -84,15 +84,16 @@ class MoveUploadsToNewDisk extends Command } - $logos = glob('public/uploads'."/setting*.*"); - $this->info("\nThere are ".count($logos).' files that might be logos.'); + $logos = glob("public/uploads/setting*.*"); + $this->info("- There are ".count($logos).' files that might be logos.'); $type_count = 0; - for ($l = 0; $l <= count($logos); $l++) { + foreach ($logos as $logo) { + $this->info($logo); $type_count++; - $filename = basename($logos[$l]); - $new_url = Storage::disk('public')->url($logos[$l], file_get_contents($public_upload[$l])); - $this->info($type_count.'. LOGO: '.$filename.' was copied to '.$new_url); + $filename = basename($logo); + Storage::disk('public')->put('uploads/'.$filename, file_get_contents($logo)); + $this->info($type_count.'. LOGO: '.$filename.' was copied to '.env('PUBLIC_AWS_URL').'/uploads/'.$filename); } $private_uploads['assets'] = glob('storage/private_uploads/assets'."/*.*"); @@ -107,8 +108,7 @@ class MoveUploadsToNewDisk extends Command foreach($private_uploads as $private_type => $private_upload) { - $this->info("\nThere are ".count($private_upload).' PRIVATE '.$private_type.' files.'); - // $this->info(print_r($private_upload, true)); + $this->info("- There are ".count($private_upload).' PRIVATE '.$private_type.' files.'); $type_count = 0; for ($x = 0; $x < count($private_upload); $x++) { diff --git a/app/Http/Requests/ImageUploadRequest.php b/app/Http/Requests/ImageUploadRequest.php index 2b43f9194d..73518880d6 100644 --- a/app/Http/Requests/ImageUploadRequest.php +++ b/app/Http/Requests/ImageUploadRequest.php @@ -49,7 +49,8 @@ class ImageUploadRequest extends Request $type = strtolower(class_basename(get_class($item))); if (is_null($path)) { - $path = str_plural($type); + $path = 'uploads/'; + $path .= str_plural($type); if ($type == 'assetmodel') { $path = 'models'; diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 121286459b..e5e5be6a85 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -731,14 +731,14 @@ @if ($asset->image)
@elseif (($asset->model) && ($asset->model->image!='')) @endif