mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
feature: extend search capabilities to other assets attributes
This commit is contained in:
parent
c1c9c3554e
commit
b804791ff6
|
@ -478,9 +478,14 @@ class AssetsController extends Controller
|
||||||
$tag = $tag ? $tag : $request->get('assetTag');
|
$tag = $tag ? $tag : $request->get('assetTag');
|
||||||
$topsearch = ($request->get('topsearch') == 'true');
|
$topsearch = ($request->get('topsearch') == 'true');
|
||||||
|
|
||||||
if (! $asset = Asset::where('asset_tag', '=', $tag)->first()) {
|
// Search for an exact and unique asset tag match
|
||||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
$assets = Asset::where('asset_tag', '=', $tag);
|
||||||
|
|
||||||
|
// If not a unique result, redirect to the index view
|
||||||
|
if ($assets->count() != 1) {
|
||||||
|
return redirect()->route('hardware.index')->with('search', $tag);
|
||||||
}
|
}
|
||||||
|
$asset = $assets->first();
|
||||||
$this->authorize('view', $asset);
|
$this->authorize('view', $asset);
|
||||||
|
|
||||||
return redirect()->route('hardware.show', $asset->id)->with('topsearch', $topsearch);
|
return redirect()->route('hardware.show', $asset->id)->with('topsearch', $topsearch);
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
data-pagination="true"
|
data-pagination="true"
|
||||||
data-id-table="assetsListingTable"
|
data-id-table="assetsListingTable"
|
||||||
data-search="true"
|
data-search="true"
|
||||||
|
data-search-text="{{ e(Session::get('search')) }}"
|
||||||
data-side-pagination="server"
|
data-side-pagination="server"
|
||||||
data-show-columns="true"
|
data-show-columns="true"
|
||||||
data-show-export="true"
|
data-show-export="true"
|
||||||
|
|
Loading…
Reference in a new issue