mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Merge pull request #11431 from ntbutler-nbcs/develop
[Fix / Minor Change] Asset checkinbytag now consistent with existingAPI
This commit is contained in:
commit
418ce75a9f
|
@ -941,18 +941,21 @@ class AssetsController extends Controller
|
||||||
* @since [v6.0]
|
* @since [v6.0]
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function checkinByTag(Request $request)
|
public function checkinByTag(Request $request, $tag = null)
|
||||||
{
|
{
|
||||||
$this->authorize('checkin', Asset::class);
|
$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) {
|
if ($asset) {
|
||||||
return $this->checkin($request, $asset->id);
|
return $this->checkin($request, $asset->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', [
|
return response()->json(Helper::formatStandardApiResponse('error', [
|
||||||
'asset'=> e($request->input('asset_tag'))
|
'asset'=> e($tag)
|
||||||
], 'Asset with tag '.e($request->input('asset_tag')).' not found'));
|
], 'Asset with tag '.e($tag).' not found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -482,6 +482,20 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
|
||||||
]
|
]
|
||||||
)->name('api.assets.checkout.bytag');
|
)->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}',
|
Route::get('byserial/{any}',
|
||||||
[
|
[
|
||||||
Api\AssetsController::class,
|
Api\AssetsController::class,
|
||||||
|
@ -511,13 +525,6 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
|
||||||
]
|
]
|
||||||
)->name('api.asset.checkin');
|
)->name('api.asset.checkin');
|
||||||
|
|
||||||
Route::post('checkinbytag',
|
|
||||||
[
|
|
||||||
Api\AssetsController::class,
|
|
||||||
'checkinbytag'
|
|
||||||
]
|
|
||||||
)->name('api.asset.checkinbytag');
|
|
||||||
|
|
||||||
Route::post('{id}/checkout',
|
Route::post('{id}/checkout',
|
||||||
[
|
[
|
||||||
Api\AssetsController::class,
|
Api\AssetsController::class,
|
||||||
|
|
Loading…
Reference in a new issue