mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Add accessories endpoint to user API (#6775)
This commit is contained in:
parent
cf086b711e
commit
9575cd2651
|
@ -12,6 +12,7 @@ use App\Http\Requests\SaveUserRequest;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use App\Http\Transformers\AssetsTransformer;
|
use App\Http\Transformers\AssetsTransformer;
|
||||||
use App\Http\Transformers\SelectlistTransformer;
|
use App\Http\Transformers\SelectlistTransformer;
|
||||||
|
use App\Http\Transformers\AccessoriesTransformer;
|
||||||
|
|
||||||
class UsersController extends Controller
|
class UsersController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -302,6 +303,23 @@ class UsersController extends Controller
|
||||||
return (new AssetsTransformer)->transformAssets($assets, $assets->count());
|
return (new AssetsTransformer)->transformAssets($assets, $assets->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the user's two-factor status
|
* Reset the user's two-factor status
|
||||||
*
|
*
|
||||||
|
|
|
@ -715,6 +715,13 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Route::get('{user}/accessories',
|
||||||
|
[
|
||||||
|
'as' => 'api.users.accessorieslist',
|
||||||
|
'uses' => 'UsersController@accessories'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
Route::post('{user}/upload',
|
Route::post('{user}/upload',
|
||||||
[
|
[
|
||||||
'as' => 'api.users.uploads',
|
'as' => 'api.users.uploads',
|
||||||
|
|
Loading…
Reference in a new issue