mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Also related to #3888
This commit is contained in:
parent
fba3949530
commit
bf157773c8
|
@ -9,6 +9,7 @@ use App\Models\Company;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Http\Requests\SaveUserRequest;
|
use App\Http\Requests\SaveUserRequest;
|
||||||
|
use App\Models\Asset;
|
||||||
|
|
||||||
class UsersController extends Controller
|
class UsersController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -182,4 +183,19 @@ class UsersController extends Controller
|
||||||
}
|
}
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.error.delete')));
|
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/users/message.error.delete')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return JSON containing a list of assets assigned to a user.
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @since [v3.0]
|
||||||
|
* @param $userId
|
||||||
|
* @return string JSON
|
||||||
|
*/
|
||||||
|
public function assets($id)
|
||||||
|
{
|
||||||
|
$this->authorize('view', User::class);
|
||||||
|
$assets = Asset::where('assigned_to', '=', $id)->with('model')->get();
|
||||||
|
return response()->json($assets);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,7 +540,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
||||||
Route::get('{user}/assets',
|
Route::get('{user}/assets',
|
||||||
[
|
[
|
||||||
'as' => 'api.users.assetlist',
|
'as' => 'api.users.assetlist',
|
||||||
'uses' => 'UsersController@getAssetList'
|
'uses' => 'UsersController@assets'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue