mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Added asset checkoutByTag API endpoint
This commit is contained in:
parent
df5b01492c
commit
67e9b7795a
|
@ -746,7 +746,21 @@ class AssetsController extends Controller
|
|||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checkout an asset by its tag.
|
||||
*
|
||||
* @author [N. Butler]
|
||||
* @param string $tag
|
||||
* @since [v6.0.5]
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function checkoutByTag(AssetCheckoutRequest $request, $tag)
|
||||
{
|
||||
if ($asset = Asset::with('assetstatus')->with('assignedTo')->where('asset_tag', $tag)->first()) {
|
||||
return $this->checkout($request, $asset->id);
|
||||
}
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, 'Asset not found'), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout an asset
|
||||
|
|
|
@ -441,6 +441,13 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
|
|||
)->name('api.assets.show.bytag')
|
||||
->where('any', '.*');
|
||||
|
||||
Route::post('bytag/{any}/checkout',
|
||||
[
|
||||
Api\AssetsController::class,
|
||||
'checkoutByTag'
|
||||
]
|
||||
)->name('api.assets.checkout.bytag');
|
||||
|
||||
Route::get('byserial/{any}',
|
||||
[
|
||||
Api\AssetsController::class,
|
||||
|
|
Loading…
Reference in a new issue