One more time…. Fixed #6704 - don’t apply gate to $arrays collection, just check that they can view assets

This commit is contained in:
snipe 2019-02-13 04:46:19 -08:00
parent 30b1cfabf5
commit aa1e06f021

View file

@ -305,9 +305,10 @@ class AssetsController extends Controller
*/ */
public function showBySerial($serial) public function showBySerial($serial)
{ {
$this->authorize('index', Asset::class);
if ($assets = Asset::with('assetstatus')->with('assignedTo') if ($assets = Asset::with('assetstatus')->with('assignedTo')
->withTrashed()->where('serial',$serial)->get()) { ->withTrashed()->where('serial',$serial)->get()) {
$this->authorize('view', $assets);
return (new AssetsTransformer)->transformAssets($assets, $assets->count()); return (new AssetsTransformer)->transformAssets($assets, $assets->count());
} }
return response()->json(Helper::formatStandardApiResponse('error', null, 'Asset not found'), 200); return response()->json(Helper::formatStandardApiResponse('error', null, 'Asset not found'), 200);