Added asset checkoutByTag API endpoint

This commit is contained in:
Nathan Butler 2022-06-29 16:11:57 +10:00
parent df5b01492c
commit 67e9b7795a
2 changed files with 22 additions and 1 deletions

View file

@ -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

View file

@ -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,