diff --git a/app/Http/Controllers/Accessories/AccessoriesFilesController.php b/app/Http/Controllers/Accessories/AccessoriesFilesController.php index ebc1e4b8e0d8..c251166ce2ed 100644 --- a/app/Http/Controllers/Accessories/AccessoriesFilesController.php +++ b/app/Http/Controllers/Accessories/AccessoriesFilesController.php @@ -51,7 +51,7 @@ public function store(UploadFileRequest $request, $accessoryId = null) : Redirec } - return redirect()->route('accessories.show', $accessory->id)->with('success', trans('general.file_upload_success')); + return redirect()->route('accessories.show', $accessory->id)->withFragment('files')->with('success', trans('general.file_upload_success')); } @@ -90,8 +90,7 @@ public function destroy($accessoryId = null, $fileId = null) : RedirectResponse $log->delete(); - return redirect()->back() - ->with('success', trans('admin/hardware/message.deletefile.success')); + return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success')); } // Redirect to the licence management page diff --git a/app/Http/Controllers/AssetModelsFilesController.php b/app/Http/Controllers/AssetModelsFilesController.php index c905282cc56a..11ede43c640b 100644 --- a/app/Http/Controllers/AssetModelsFilesController.php +++ b/app/Http/Controllers/AssetModelsFilesController.php @@ -44,10 +44,10 @@ public function store(UploadFileRequest $request, $modelId = null) : RedirectRes $model->logUpload($file_name, $request->get('notes')); } - return redirect()->back()->with('success', trans('general.file_upload_success')); + return redirect()->back()->withFragment('files')->with('success', trans('general.file_upload_success')); } - return redirect()->back()->with('error', trans('admin/hardware/message.upload.nofiles')); + return redirect()->back()->withFragment('files')->with('error', trans('admin/hardware/message.upload.nofiles')); } /** @@ -119,11 +119,10 @@ public function destroy($modelId = null, $fileId = null) : RedirectResponse } $log->delete(); - return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success')); + return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success')); } - return redirect()->back() - ->with('success', trans('admin/hardware/message.deletefile.success')); + return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success')); } // Redirect to the hardware management page diff --git a/app/Http/Controllers/Assets/AssetFilesController.php b/app/Http/Controllers/Assets/AssetFilesController.php index d15055c4b2fb..96011728f99a 100644 --- a/app/Http/Controllers/Assets/AssetFilesController.php +++ b/app/Http/Controllers/Assets/AssetFilesController.php @@ -45,7 +45,7 @@ public function store(UploadFileRequest $request, $assetId = null) : RedirectRes $asset->logUpload($file_name, $request->get('notes')); } - return redirect()->back()->with('success', trans('admin/hardware/message.upload.success')); + return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.upload.success')); } return redirect()->back()->with('error', trans('admin/hardware/message.upload.nofiles')); @@ -97,25 +97,19 @@ public function show($assetId = null, $fileId = null) : View | RedirectResponse */ public function destroy($assetId = null, $fileId = null) : RedirectResponse { - $asset = Asset::find($assetId); - $this->authorize('update', $asset); - $rel_path = 'private_uploads/assets'; - - // the asset is valid - if (isset($asset->id)) { + if ($asset = Asset::find($assetId)) { $this->authorize('update', $asset); - $log = Actionlog::find($fileId); - if ($log) { + $rel_path = 'private_uploads/assets'; + + if ($log = Actionlog::find($fileId)) { if (Storage::exists($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()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success')); } - return redirect()->back() - ->with('success', trans('admin/hardware/message.deletefile.success')); + return redirect()->route('hardware.show', ['hardware' => $asset])->with('error', trans('general.log_record_not_found')); } return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); diff --git a/app/Http/Controllers/Components/ComponentsFilesController.php b/app/Http/Controllers/Components/ComponentsFilesController.php index 83468a0b10b4..b5e30aa694fd 100644 --- a/app/Http/Controllers/Components/ComponentsFilesController.php +++ b/app/Http/Controllers/Components/ComponentsFilesController.php @@ -50,7 +50,7 @@ public function store(UploadFileRequest $request, $componentId = null) } - return redirect()->route('components.show', $component->id)->with('success', trans('general.file_upload_success')); + return redirect()->route('components.show', $component->id)->withFragment('files')->with('success', trans('general.file_upload_success')); } @@ -91,7 +91,7 @@ public function destroy($componentId = null, $fileId = null) $log->delete(); - return redirect()->back() + return redirect()->back()->withFragment('files') ->with('success', trans('admin/hardware/message.deletefile.success')); } diff --git a/app/Http/Controllers/Consumables/ConsumablesFilesController.php b/app/Http/Controllers/Consumables/ConsumablesFilesController.php index 054fdc0b81a9..545b008dc0b1 100644 --- a/app/Http/Controllers/Consumables/ConsumablesFilesController.php +++ b/app/Http/Controllers/Consumables/ConsumablesFilesController.php @@ -48,7 +48,7 @@ public function store(UploadFileRequest $request, $consumableId = null) } - return redirect()->route('consumables.show', $consumable->id)->with('success', trans('general.file_upload_success')); + return redirect()->route('consumables.show', $consumable->id)->withFragment('files')->with('success', trans('general.file_upload_success')); } @@ -89,7 +89,7 @@ public function destroy($consumableId = null, $fileId = null) $log->delete(); - return redirect()->back() + return redirect()->back()->withFragment('files') ->with('success', trans('admin/hardware/message.deletefile.success')); } diff --git a/app/Http/Controllers/Users/UserFilesController.php b/app/Http/Controllers/Users/UserFilesController.php index e99bfe298f78..cae4074dd5cb 100644 --- a/app/Http/Controllers/Users/UserFilesController.php +++ b/app/Http/Controllers/Users/UserFilesController.php @@ -56,7 +56,7 @@ public function store(UploadFileRequest $request, $userId = null) $logActions[] = $logAction; } // dd($logActions); - return redirect()->back()->with('success', trans('admin/users/message.upload.success')); + return redirect()->back()->withFragment('files')->with('success', trans('admin/users/message.upload.success')); } return redirect()->back()->with('error', trans('admin/users/message.upload.nofiles')); @@ -87,7 +87,7 @@ public function destroy($userId = null, $fileId = null) if (Storage::exists($rel_path.'/'.$filename)) { Storage::delete($rel_path.'/'.$filename); - return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); + return redirect()->back()->withFragment('files')->with('success', trans('admin/users/message.deletefile.success')); } } diff --git a/app/Http/Requests/UploadFileRequest.php b/app/Http/Requests/UploadFileRequest.php index 4762e52b7533..e58f1a1be37d 100644 --- a/app/Http/Requests/UploadFileRequest.php +++ b/app/Http/Requests/UploadFileRequest.php @@ -46,8 +46,6 @@ public function handleFile(string $dirname, string $name_prefix, $file): string $extension = $file->getClientOriginalExtension(); $file_name = $name_prefix.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$file->guessExtension(); - - Log::debug("Your filetype IS: ".$file->getMimeType()); // Check for SVG and sanitize it if ($file->getMimeType() === 'image/svg+xml') { Log::debug('This is an SVG'); @@ -66,7 +64,6 @@ public function handleFile(string $dirname, string $name_prefix, $file): string } else { $put_results = Storage::put($dirname.$file_name, file_get_contents($file)); - Log::debug("Here are the '$put_results' (should be 0 or 1 or true or false or something?)"); } return $file_name; } diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php index f26b9babd4b1..15ce82d67ff7 100755 --- a/resources/views/models/view.blade.php +++ b/resources/views/models/view.blade.php @@ -49,7 +49,7 @@
  • - +