mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Adds consumables endpoint to user API
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
0cfc0a4bee
commit
dc2e6c2b06
|
@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\SaveUserRequest;
|
use App\Http\Requests\SaveUserRequest;
|
||||||
use App\Http\Transformers\AccessoriesTransformer;
|
use App\Http\Transformers\AccessoriesTransformer;
|
||||||
use App\Http\Transformers\AssetsTransformer;
|
use App\Http\Transformers\AssetsTransformer;
|
||||||
|
use App\Http\Transformers\ConsumablesTransformer;
|
||||||
use App\Http\Transformers\LicensesTransformer;
|
use App\Http\Transformers\LicensesTransformer;
|
||||||
use App\Http\Transformers\SelectlistTransformer;
|
use App\Http\Transformers\SelectlistTransformer;
|
||||||
use App\Http\Transformers\UsersTransformer;
|
use App\Http\Transformers\UsersTransformer;
|
||||||
|
@ -448,6 +449,24 @@ class UsersController extends Controller
|
||||||
return (new AssetsTransformer)->transformAssets($assets, $assets->count(), $request);
|
return (new AssetsTransformer)->transformAssets($assets, $assets->count(), $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return JSON containing a list of consumables assigned to a user.
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @since [v3.0]
|
||||||
|
* @param $userId
|
||||||
|
* @return string JSON
|
||||||
|
*/
|
||||||
|
public function consumables(Request $request, $id)
|
||||||
|
{
|
||||||
|
$this->authorize('view', User::class);
|
||||||
|
$this->authorize('view', Consumable::class);
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
$consumables = $user->consumables;
|
||||||
|
return (new ConsumablesTransformer)->transformConsumables($consumables, $consumables->count(), $request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return JSON containing a list of accessories assigned to a user.
|
* Return JSON containing a list of accessories assigned to a user.
|
||||||
*
|
*
|
||||||
|
|
|
@ -858,6 +858,13 @@ Route::group(['prefix' => 'v1','namespace' => 'Api', 'middleware' => 'auth:api']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Route::get('{user}/consumables',
|
||||||
|
[
|
||||||
|
'as' => 'api.users.consumablelist',
|
||||||
|
'uses' => 'UsersController@consumables'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
Route::get('{user}/accessories',
|
Route::get('{user}/accessories',
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in a new issue