Merge branch 'features/accessories_users' into develop

# Conflicts:
#	app/Http/Controllers/Api/UsersController.php
#	config/version.php
#	routes/api.php
This commit is contained in:
snipe 2019-03-01 17:30:03 -08:00
commit 288cc01c41
2 changed files with 30 additions and 0 deletions

View file

@ -14,6 +14,7 @@ use App\Http\Requests\SaveUserRequest;
use App\Models\Asset;
use App\Http\Transformers\AssetsTransformer;
use App\Http\Transformers\SelectlistTransformer;
use App\Http\Transformers\AccessoriesTransformer;
class UsersController extends Controller
{
@ -328,6 +329,24 @@ class UsersController extends Controller
}
/**
* Return JSON containing a list of accessories assigned to a user.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v4.6.14]
* @param $userId
* @return string JSON
*/
public function accessories($id)
{
$this->authorize('view', User::class);
$user = User::findOrFail($id);
$this->authorize('view', Accessory::class);
$accessories = $user->accessories;
return (new AccessoriesTransformer)->transformAccessories($accessories, $accessories->count());
}
/**
* Return JSON containing a list of licenses assigned to a user.
*
* @author [N. Mathar] [<snipe@snipe.net>]
@ -345,6 +364,8 @@ class UsersController extends Controller
}
/**
* Reset the user's two-factor status
*
* @author [A. Gianotto] [<snipe@snipe.net>]

View file

@ -727,6 +727,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
]
);
Route::get('{user}/licenses',
[
'as' => 'api.users.licenselist',
@ -734,6 +735,14 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
]
);
Route::get('{user}/accessories',
[
'as' => 'api.users.licenselist',
'uses' => 'UsersController@licenses'
]
);
Route::post('{user}/upload',
[
'as' => 'api.users.uploads',