mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
Asset checkinbytag now consistent with existingAPI
This is a non-breaking change to the checkinbytag endpoint to bring it inline with the usage/formatting of the other bytag endpoints that currently exist - using the URL path to define the asset_tag instead of passing it through as a url query. Both methods will work, but the URL Path method will take precidence if it is used (the query will be ignored if included)
This commit is contained in:
parent
2262ef818e
commit
0617480f73
|
@ -907,18 +907,21 @@ class AssetsController extends Controller
|
|||
* @since [v6.0]
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function checkinByTag(Request $request)
|
||||
public function checkinByTag(Request $request, $tag = null)
|
||||
{
|
||||
$this->authorize('checkin', Asset::class);
|
||||
$asset = Asset::where('asset_tag', $request->input('asset_tag'))->first();
|
||||
if(null == $tag && null !== ($request->input('asset_tag'))) {
|
||||
$tag = $request->input('asset_tag');
|
||||
}
|
||||
$asset = Asset::where('asset_tag', $tag)->first();
|
||||
|
||||
if($asset) {
|
||||
return $this->checkin($request, $asset->id);
|
||||
}
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('error', [
|
||||
'asset'=> e($request->input('asset_tag'))
|
||||
], 'Asset with tag '.e($request->input('asset_tag')).' not found'));
|
||||
'asset'=> e($tag)
|
||||
], 'Asset with tag '.e($tag).' not found'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -469,6 +469,20 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
|
|||
]
|
||||
)->name('api.assets.checkout.bytag');
|
||||
|
||||
Route::post('bytag/{any}/checkin',
|
||||
[
|
||||
Api\AssetsController::class,
|
||||
'checkinbytag'
|
||||
]
|
||||
)->name('api.asset.checkinbytagPath');
|
||||
|
||||
Route::post('checkinbytag',
|
||||
[
|
||||
Api\AssetsController::class,
|
||||
'checkinbytag'
|
||||
]
|
||||
)->name('api.asset.checkinbytag');
|
||||
|
||||
Route::get('byserial/{any}',
|
||||
[
|
||||
Api\AssetsController::class,
|
||||
|
@ -498,13 +512,6 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
|
|||
]
|
||||
)->name('api.asset.checkin');
|
||||
|
||||
Route::post('checkinbytag',
|
||||
[
|
||||
Api\AssetsController::class,
|
||||
'checkinbytag'
|
||||
]
|
||||
)->name('api.asset.checkinbytag');
|
||||
|
||||
Route::post('{id}/checkout',
|
||||
[
|
||||
Api\AssetsController::class,
|
||||
|
|
Loading…
Reference in a new issue