diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 1dd119ea1c0b..069664a7f68c 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -410,7 +410,23 @@ public function destroy($assetId) return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.delete.success')); } + /** + * Searches the assets table by serial, and redirects if it finds one + * + * @author [A. Gianotto] [] + * @since [v3.0] + * @return Redirect + */ + public function getAssetBySerial(Request $request) + { + $topsearch = ($request->get('topsearch')=="true"); + if (!$asset = Asset::where('serial', '=', $request->get('serial'))->first()) { + return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); + } + $this->authorize('view', $asset); + return redirect()->route('hardware.show', $asset->id)->with('topsearch', $topsearch); + } /** * Searches the assets table by asset tag, and redirects if it finds one @@ -429,6 +445,8 @@ public function getAssetByTag(Request $request) $this->authorize('view', $asset); return redirect()->route('hardware.show', $asset->id)->with('topsearch', $topsearch); } + + /** * Return a QR code for the asset *