Skip to content

Commit

Permalink
Fixed getAssetBySerial
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <snipe@snipe.net>
  • Loading branch information
snipe committed Mar 5, 2022
1 parent f840652 commit 3e2fe10
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/Http/Controllers/Assets/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] [<snipe@snipe.net>]
* @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
Expand All @@ -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
*
Expand Down

0 comments on commit 3e2fe10

Please # to comment.