Merge branch 'develop'
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user