A free open source IT asset/license management system
Use Storage for file uploads (not model images)
snipe373885ebd1c9
diff --git a/app/Http/Controllers/Assets/AssetFilesController.php b/app/Http/Controllers/Assets/AssetFilesController.phpindex 19ed4538ff..9f31b80dc8 100644--- a/app/Http/Controllers/Assets/AssetFilesController.php+++ b/app/Http/Controllers/Assets/AssetFilesController.php@@ -107,21 +107,18 @@ class AssetFilesController extends Controller{$asset = Asset::find($assetId);$this->authorize('update', $asset);- $destinationPath = config('app.private_uploads').'/imports/assets';+ $rel_path = 'storage/private_uploads/assets';// the asset is validif (isset($asset->id)) {$this->authorize('update', $asset);-$log = Actionlog::find($fileId);- $full_filename = $destinationPath.'/'.$log->filename;- if (file_exists($full_filename)) {- \Log::debug('Trying to delete '.$full_filename);- Storage::delete($full_filename);- //unlink($destinationPath.'/'.$log->filename);+ if (file_exists(base_path().'/'.$rel_path.'/'.$log->filename)) {+ Storage::delete($rel_path.'/'.$log->filename);}$log->delete();- return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success'));+ return redirect()->back()+ ->with('success', trans('admin/hardware/message.deletefile.success'));}// Redirect to the hardware management pagediff --git a/app/Http/Controllers/Licenses/LicenseFilesController.php b/app/Http/Controllers/Licenses/LicenseFilesController.phpindex e17f281a9e..a25b15ada2 100644--- a/app/Http/Controllers/Licenses/LicenseFilesController.php+++ b/app/Http/Controllers/Licenses/LicenseFilesController.php@@ -75,19 +75,19 @@ class LicenseFilesController extends Controllerpublic function destroy($licenseId = null, $fileId = null){$license = License::find($licenseId);- $destinationPath = config('app.private_uploads').'/licenses';- // the license is valid+ $rel_path = 'storage/private_uploads/licenses';++ // the asset is validif (isset($license->id)) {- $this->authorize('edit', $license);+ $this->authorize('update', $license);$log = Actionlog::find($fileId);- $full_filename = $destinationPath.'/'.$log->filename;- if (file_exists($full_filename)) {- Storage::delete($full_filename);- // unlink($destinationPath.'/'.$log->filename);+ if (file_exists(base_path().'/'.$rel_path.'/'.$log->filename)) {+ Storage::delete($rel_path.'/'.$log->filename);}$log->delete();- return redirect()->back()->with('success', trans('admin/licenses/message.deletefile.success'));+ return redirect()->back()+ ->with('success', trans('admin/hardware/message.deletefile.success'));}// Redirect to the licence management pagediff --git a/composer.json b/composer.jsonindex ab1a0d0a1d..9d2b87d204 100644--- a/composer.json+++ b/composer.json@@ -42,6 +42,7 @@"watson/validating": "^3.0"},"require-dev": {+ "barryvdh/laravel-ide-helper": "^2.4","codeception/codeception": "^2.4","filp/whoops": "~2.0","fzaninotto/faker": "~1.4",@@ -72,6 +73,11 @@]},"scripts": {+ "post-update-cmd": [+ "Illuminate\\Foundation\\ComposerScripts::postUpdate",+ "php artisan ide-helper:generate",+ "php artisan ide-helper:meta"+ ],"post-autoload-dump": ["Illuminate\\Foundation\\ComposerScripts::postAutoloadDump","@php artisan package:discover"