Merge branch 'develop'

This commit is contained in:
snipe
2018-03-23 16:20:09 -07:00
3 changed files with 51 additions and 0 deletions
+1
View File
@@ -7,6 +7,7 @@ APP_KEY=ChangeMe
APP_URL=null
APP_TIMEZONE='UTC'
APP_LOCALE=en
BACKUP_ENV=false
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
@@ -274,6 +274,44 @@ class AssetsController extends Controller
}
/**
* Returns JSON with information about an asset (by tag) for detail view.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @param string $tag
* @since [v4.2.1]
* @return JsonResponse
*/
public function showByTag($tag)
{
if ($asset = Asset::with('assetstatus')->with('assignedTo')->withTrashed()->where('asset_tag',$tag)->first()) {
$this->authorize('view', $asset);
return (new AssetsTransformer)->transformAsset($asset);
}
return response()->json(Helper::formatStandardApiResponse('error', null, 'Asset not found'), 404);
}
/**
* Returns JSON with information about an asset (by serial) for detail view.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @param string $serial
* @since [v4.2.1]
* @return JsonResponse
*/
public function showBySerial($serial)
{
if ($assets = Asset::with('assetstatus')->with('assignedTo')
->withTrashed()->where('serial',$serial)->get()) {
$this->authorize('view', $assets);
return (new AssetsTransformer)->transformAssets($assets, $assets->count());
}
return response()->json(Helper::formatStandardApiResponse('error', null, 'Asset not found'), 404);
}
/**
* Returns JSON with information about an asset for detail view.
*
@@ -289,6 +327,7 @@ class AssetsController extends Controller
return (new AssetsTransformer)->transformAsset($asset);
}
}
+11
View File
@@ -283,6 +283,17 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
Route::group(['prefix' => 'hardware'], function () {
Route::get( 'bytag/{tag}', [
'as' => 'assets.show.bytag',
'uses' => 'AssetsController@showByTag'
]);
Route::get( 'byserial/{serial}', [
'as' => 'assets.show.byserial',
'uses' => 'AssetsController@showBySerial'
]);
Route::get( 'selectlist', [
'as' => 'assets.selectlist',
'uses' => 'AssetsController@selectlist'