mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 13:57:41 -08:00
parent
fdd6ddf61b
commit
66f557d436
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Transformers\LicensesTransformer;
|
||||||
|
use App\Models\License;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Transformers\UsersTransformer;
|
use App\Http\Transformers\UsersTransformer;
|
||||||
|
@ -314,6 +316,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 licenses assigned to a user.
|
||||||
|
*
|
||||||
|
* @author [N. Mathar] [<snipe@snipe.net>]
|
||||||
|
* @since [v5.0]
|
||||||
|
* @param $userId
|
||||||
|
* @return string JSON
|
||||||
|
*/
|
||||||
|
public function licenses($id)
|
||||||
|
{
|
||||||
|
$this->authorize('view', User::class);
|
||||||
|
$this->authorize('view', License::class);
|
||||||
|
$user = User::where('id', $id)->withTrashed()->first();
|
||||||
|
$licenses = $user->licenses()->get();
|
||||||
|
return (new LicensesTransformer())->transformLicenses($licenses, $licenses->count());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the user's two-factor status
|
* Reset the user's two-factor status
|
||||||
*
|
*
|
||||||
|
|
|
@ -722,6 +722,13 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Route::get('{user}/licenses',
|
||||||
|
[
|
||||||
|
'as' => 'api.users.licenselist',
|
||||||
|
'uses' => 'UsersController@licenses'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
Route::post('{user}/upload',
|
Route::post('{user}/upload',
|
||||||
[
|
[
|
||||||
'as' => 'api.users.uploads',
|
'as' => 'api.users.uploads',
|
||||||
|
|
Loading…
Reference in a new issue